From 63b34dc6ccd32c9bc7c3d8c0137ff12530238bde Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 30 Oct 2008 01:50:51 +0100 Subject: reKonq initial commit. Yeah! --- AUTHORS | 1 + CMakeLists.txt | 22 + src/CMakeLists.txt | 53 ++ src/addbookmarkdialog.ui | 98 +++ src/autosaver.cpp | 90 +++ src/autosaver.h | 72 ++ src/bookmarks.cpp | 983 ++++++++++++++++++++++++ src/bookmarks.h | 306 ++++++++ src/bookmarks.ui | 106 +++ src/browser.icns | Bin 0 -> 57624 bytes src/browser.ico | Bin 0 -> 287934 bytes src/browser.pro | 87 +++ src/browser.rc | 2 + src/browserapplication.cpp | 439 +++++++++++ src/browserapplication.h | 115 +++ src/browsermainwindow.cpp | 969 ++++++++++++++++++++++++ src/browsermainwindow.h | 164 +++++ src/chasewidget.cpp | 138 ++++ src/chasewidget.h | 81 ++ src/cookiejar.cpp | 728 ++++++++++++++++++ src/cookiejar.h | 200 +++++ src/cookies.ui | 106 +++ src/cookiesexceptions.ui | 184 +++++ src/data/addtab.png | Bin 0 -> 469 bytes src/data/browser.svg | 1598 ++++++++++++++++++++++++++++++++++++++++ src/data/closetab.png | Bin 0 -> 516 bytes src/data/data.qrc | 11 + src/data/defaultbookmarks.xbel | 40 + src/data/defaulticon.png | Bin 0 -> 1473 bytes src/data/history.png | Bin 0 -> 1527 bytes src/data/loading.gif | Bin 0 -> 847 bytes src/downloaditem.ui | 134 ++++ src/downloadmanager.cpp | 575 +++++++++++++++ src/downloadmanager.h | 158 ++++ src/downloads.ui | 83 +++ src/edittableview.cpp | 73 ++ src/edittableview.h | 57 ++ src/edittreeview.cpp | 73 ++ src/edittreeview.h | 57 ++ src/history.cpp | 1277 ++++++++++++++++++++++++++++++++ src/history.h | 346 +++++++++ src/history.ui | 106 +++ src/htmls/htmls.qrc | 5 + src/htmls/notfound.html | 63 ++ src/main.cpp | 57 ++ src/modelmenu.cpp | 222 ++++++ src/modelmenu.h | 101 +++ src/networkaccessmanager.cpp | 154 ++++ src/networkaccessmanager.h | 61 ++ src/passworddialog.ui | 111 +++ src/proxy.ui | 104 +++ src/searchlineedit.cpp | 233 ++++++ src/searchlineedit.h | 99 +++ src/settings.cpp | 320 ++++++++ src/settings.h | 70 ++ src/settings.ui | 614 +++++++++++++++ src/squeezelabel.cpp | 56 ++ src/squeezelabel.h | 56 ++ src/tabwidget.cpp | 859 +++++++++++++++++++++ src/tabwidget.h | 222 ++++++ src/toolbarsearch.cpp | 156 ++++ src/toolbarsearch.h | 80 ++ src/urllineedit.cpp | 327 ++++++++ src/urllineedit.h | 109 +++ src/webview.cpp | 299 ++++++++ src/webview.h | 115 +++ src/xbel.cpp | 315 ++++++++ src/xbel.h | 109 +++ 68 files changed, 14449 insertions(+) create mode 100644 AUTHORS create mode 100644 CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/addbookmarkdialog.ui create mode 100644 src/autosaver.cpp create mode 100644 src/autosaver.h create mode 100644 src/bookmarks.cpp create mode 100644 src/bookmarks.h create mode 100644 src/bookmarks.ui create mode 100644 src/browser.icns create mode 100644 src/browser.ico create mode 100644 src/browser.pro create mode 100644 src/browser.rc create mode 100644 src/browserapplication.cpp create mode 100644 src/browserapplication.h create mode 100644 src/browsermainwindow.cpp create mode 100644 src/browsermainwindow.h create mode 100644 src/chasewidget.cpp create mode 100644 src/chasewidget.h create mode 100644 src/cookiejar.cpp create mode 100644 src/cookiejar.h create mode 100644 src/cookies.ui create mode 100644 src/cookiesexceptions.ui create mode 100644 src/data/addtab.png create mode 100644 src/data/browser.svg create mode 100644 src/data/closetab.png create mode 100644 src/data/data.qrc create mode 100644 src/data/defaultbookmarks.xbel create mode 100644 src/data/defaulticon.png create mode 100644 src/data/history.png create mode 100644 src/data/loading.gif create mode 100644 src/downloaditem.ui create mode 100644 src/downloadmanager.cpp create mode 100644 src/downloadmanager.h create mode 100644 src/downloads.ui create mode 100644 src/edittableview.cpp create mode 100644 src/edittableview.h create mode 100644 src/edittreeview.cpp create mode 100644 src/edittreeview.h create mode 100644 src/history.cpp create mode 100644 src/history.h create mode 100644 src/history.ui create mode 100644 src/htmls/htmls.qrc create mode 100755 src/htmls/notfound.html create mode 100644 src/main.cpp create mode 100644 src/modelmenu.cpp create mode 100644 src/modelmenu.h create mode 100644 src/networkaccessmanager.cpp create mode 100644 src/networkaccessmanager.h create mode 100644 src/passworddialog.ui create mode 100644 src/proxy.ui create mode 100644 src/searchlineedit.cpp create mode 100644 src/searchlineedit.h create mode 100644 src/settings.cpp create mode 100644 src/settings.h create mode 100644 src/settings.ui create mode 100644 src/squeezelabel.cpp create mode 100644 src/squeezelabel.h create mode 100644 src/tabwidget.cpp create mode 100644 src/tabwidget.h create mode 100644 src/toolbarsearch.cpp create mode 100644 src/toolbarsearch.h create mode 100644 src/urllineedit.cpp create mode 100644 src/urllineedit.h create mode 100644 src/webview.cpp create mode 100644 src/webview.h create mode 100644 src/xbel.cpp create mode 100644 src/xbel.h diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..187011aa --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Andrea Diamantini adjam7@gmail.com diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..78d320d6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,22 @@ +# Andrea Diamantini - adjam7 at gmail dot com +# rekonq project + +PROJECT( rekonq ) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) + +SET( QT_MIN_VERSION 4.4.0) +FIND_PACKAGE( KDE4 REQUIRED ) + +INCLUDE(KDE4Defaults) +INCLUDE(MacroLibrary) + +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${KDE4_INCLUDES} + ${QT4_INCLUDES} + ${QT_QTNETWORK_INCLUDE_DIR} + ${QT_QTWEBKIT_INCLUDE_DIR} +) + +ADD_SUBDIRECTORY( src ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..26283c2e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,53 @@ +SET( rekonq_SRCS + autosaver.cpp + bookmarks.cpp + browserapplication.cpp + browsermainwindow.cpp + chasewidget.cpp + cookiejar.cpp + downloadmanager.cpp + edittableview.cpp + edittreeview.cpp + history.cpp + modelmenu.cpp + networkaccessmanager.cpp + searchlineedit.cpp + settings.cpp + squeezelabel.cpp + tabwidget.cpp + toolbarsearch.cpp + urllineedit.cpp + webview.cpp + xbel.cpp + main.cpp +) + +KDE4_ADD_UI_FILES( rekonq_SRCS + addbookmarkdialog.ui + bookmarks.ui + cookies.ui + cookiesexceptions.ui + downloaditem.ui + downloads.ui + history.ui + passworddialog.ui + proxy.ui + settings.ui + ) + +# include(${QT_USE_FILE}) + +ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ) + +KDE4_ADD_EXECUTABLE( rekonq ${rekonq_SRCS} ) + +TARGET_LINK_LIBRARIES( rekonq + ${QT_LIBRARIES} + ${QT_QTNETWORK_LIBRARY} + ${QT_QTWEBKIT_LIBRARY} + ${KDE4_KDEUI_LIBS} + ${QT_QTUITOOLS_LIBRARY} +) + +INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} ) +# install(FILES kekonq.rc DESTINATION ${DATA_INSTALL_DIR}/rekonq) diff --git a/src/addbookmarkdialog.ui b/src/addbookmarkdialog.ui new file mode 100644 index 00000000..3460d7bb --- /dev/null +++ b/src/addbookmarkdialog.ui @@ -0,0 +1,98 @@ + + AddBookmarkDialog + + + + 0 + 0 + 240 + 168 + + + + Add Bookmark + + + + + + Type a name for the bookmark, and choose where to keep it. + + + Qt::PlainText + + + true + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 2 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + false + + + + + + + + + buttonBox + accepted() + AddBookmarkDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AddBookmarkDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/autosaver.cpp b/src/autosaver.cpp new file mode 100644 index 00000000..f8d088dd --- /dev/null +++ b/src/autosaver.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "autosaver.h" + +#include +#include +#include +#include + +#define AUTOSAVE_IN 1000 * 3 // seconds +#define MAXWAIT 1000 * 15 // seconds + +AutoSaver::AutoSaver(QObject *parent) : QObject(parent) +{ + Q_ASSERT(parent); +} + +AutoSaver::~AutoSaver() +{ + if (m_timer.isActive()) + qWarning() << "AutoSaver: still active when destroyed, changes not saved."; +} + +void AutoSaver::changeOccurred() +{ + if (m_firstChange.isNull()) + m_firstChange.start(); + + if (m_firstChange.elapsed() > MAXWAIT) { + saveIfNeccessary(); + } else { + m_timer.start(AUTOSAVE_IN, this); + } +} + +void AutoSaver::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == m_timer.timerId()) { + saveIfNeccessary(); + } else { + QObject::timerEvent(event); + } +} + +void AutoSaver::saveIfNeccessary() +{ + if (!m_timer.isActive()) + return; + m_timer.stop(); + m_firstChange = QTime(); + if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) { + qWarning() << "AutoSaver: error invoking slot save() on parent"; + } +} + diff --git a/src/autosaver.h b/src/autosaver.h new file mode 100644 index 00000000..162b3b6c --- /dev/null +++ b/src/autosaver.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef AUTOSAVER_H +#define AUTOSAVER_H + +#include +#include +#include + +/* + This class will call the save() slot on the parent object when the parent changes. + It will wait several seconds after changed() to combining multiple changes and + prevent continuous writing to disk. + */ +class AutoSaver : public QObject { + +Q_OBJECT + +public: + AutoSaver(QObject *parent); + ~AutoSaver(); + void saveIfNeccessary(); + +public slots: + void changeOccurred(); + +protected: + void timerEvent(QTimerEvent *event); + +private: + QBasicTimer m_timer; + QTime m_firstChange; + +}; + +#endif // AUTOSAVER_H + diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp new file mode 100644 index 00000000..9b47747d --- /dev/null +++ b/src/bookmarks.cpp @@ -0,0 +1,983 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "bookmarks.h" + +#include "autosaver.h" +#include "browserapplication.h" +#include "history.h" +#include "xbel.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define BOOKMARKBAR "Bookmarks Bar" +#define BOOKMARKMENU "Bookmarks Menu" + +BookmarksManager::BookmarksManager(QObject *parent) + : QObject(parent) + , m_loaded(false) + , m_saveTimer(new AutoSaver(this)) + , m_bookmarkRootNode(0) + , m_bookmarkModel(0) +{ + connect(this, SIGNAL(entryAdded(BookmarkNode *)), + m_saveTimer, SLOT(changeOccurred())); + connect(this, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), + m_saveTimer, SLOT(changeOccurred())); + connect(this, SIGNAL(entryChanged(BookmarkNode *)), + m_saveTimer, SLOT(changeOccurred())); +} + +BookmarksManager::~BookmarksManager() +{ + m_saveTimer->saveIfNeccessary(); +} + +void BookmarksManager::changeExpanded() +{ + m_saveTimer->changeOccurred(); +} + +void BookmarksManager::load() +{ + if (m_loaded) + return; + m_loaded = true; + + QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); + if (!QFile::exists(bookmarkFile)) + bookmarkFile = QLatin1String(":defaultbookmarks.xbel"); + + XbelReader reader; + m_bookmarkRootNode = reader.read(bookmarkFile); + if (reader.error() != QXmlStreamReader::NoError) { + QMessageBox::warning(0, QLatin1String("Loading Bookmark"), + tr("Error when loading bookmarks on line %1, column %2:\n" + "%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString())); + } + + BookmarkNode *toolbar = 0; + BookmarkNode *menu = 0; + QList others; + for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { + BookmarkNode *node = m_bookmarkRootNode->children().at(i); + if (node->type() == BookmarkNode::Folder) { + // Automatically convert + if (node->title == tr("Toolbar Bookmarks") && !toolbar) { + node->title = tr(BOOKMARKBAR); + } + if (node->title == tr(BOOKMARKBAR) && !toolbar) { + toolbar = node; + } + + // Automatically convert + if (node->title == tr("Menu") && !menu) { + node->title = tr(BOOKMARKMENU); + } + if (node->title == tr(BOOKMARKMENU) && !menu) { + menu = node; + } + } else { + others.append(node); + } + m_bookmarkRootNode->remove(node); + } + Q_ASSERT(m_bookmarkRootNode->children().count() == 0); + if (!toolbar) { + toolbar = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); + toolbar->title = tr(BOOKMARKBAR); + } else { + m_bookmarkRootNode->add(toolbar); + } + + if (!menu) { + menu = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); + menu->title = tr(BOOKMARKMENU); + } else { + m_bookmarkRootNode->add(menu); + } + + for (int i = 0; i < others.count(); ++i) + menu->add(others.at(i)); +} + +void BookmarksManager::save() const +{ + if (!m_loaded) + return; + + XbelWriter writer; + QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); + if (!writer.write(bookmarkFile, m_bookmarkRootNode)) + qWarning() << "BookmarkManager: error saving to" << bookmarkFile; +} + +void BookmarksManager::addBookmark(BookmarkNode *parent, BookmarkNode *node, int row) +{ + if (!m_loaded) + return; + Q_ASSERT(parent); + InsertBookmarksCommand *command = new InsertBookmarksCommand(this, parent, node, row); + m_commands.push(command); +} + +void BookmarksManager::removeBookmark(BookmarkNode *node) +{ + if (!m_loaded) + return; + + Q_ASSERT(node); + BookmarkNode *parent = node->parent(); + int row = parent->children().indexOf(node); + RemoveBookmarksCommand *command = new RemoveBookmarksCommand(this, parent, row); + m_commands.push(command); +} + +void BookmarksManager::setTitle(BookmarkNode *node, const QString &newTitle) +{ + if (!m_loaded) + return; + + Q_ASSERT(node); + ChangeBookmarkCommand *command = new ChangeBookmarkCommand(this, node, newTitle, true); + m_commands.push(command); +} + +void BookmarksManager::setUrl(BookmarkNode *node, const QString &newUrl) +{ + if (!m_loaded) + return; + + Q_ASSERT(node); + ChangeBookmarkCommand *command = new ChangeBookmarkCommand(this, node, newUrl, false); + m_commands.push(command); +} + +BookmarkNode *BookmarksManager::bookmarks() +{ + if (!m_loaded) + load(); + return m_bookmarkRootNode; +} + +BookmarkNode *BookmarksManager::menu() +{ + if (!m_loaded) + load(); + + for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { + BookmarkNode *node = m_bookmarkRootNode->children().at(i); + if (node->title == tr(BOOKMARKMENU)) + return node; + } + Q_ASSERT(false); + return 0; +} + +BookmarkNode *BookmarksManager::toolbar() +{ + if (!m_loaded) + load(); + + for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { + BookmarkNode *node = m_bookmarkRootNode->children().at(i); + if (node->title == tr(BOOKMARKBAR)) + return node; + } + Q_ASSERT(false); + return 0; +} + +BookmarksModel *BookmarksManager::bookmarksModel() +{ + if (!m_bookmarkModel) + m_bookmarkModel = new BookmarksModel(this, this); + return m_bookmarkModel; +} + +void BookmarksManager::importBookmarks() +{ + QString fileName = QFileDialog::getOpenFileName(0, tr("Open File"), + QString(), + tr("XBEL (*.xbel *.xml)")); + if (fileName.isEmpty()) + return; + + XbelReader reader; + BookmarkNode *importRootNode = reader.read(fileName); + if (reader.error() != QXmlStreamReader::NoError) { + QMessageBox::warning(0, QLatin1String("Loading Bookmark"), + tr("Error when loading bookmarks on line %1, column %2:\n" + "%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString())); + } + + importRootNode->setType(BookmarkNode::Folder); + importRootNode->title = (tr("Imported %1").arg(QDate::currentDate().toString(Qt::SystemLocaleShortDate))); + addBookmark(menu(), importRootNode); +} + +void BookmarksManager::exportBookmarks() +{ + QString fileName = QFileDialog::getSaveFileName(0, tr("Save File"), + tr("%1 Bookmarks.xbel").arg(QCoreApplication::applicationName()), + tr("XBEL (*.xbel *.xml)")); + if (fileName.isEmpty()) + return; + + XbelWriter writer; + if (!writer.write(fileName, m_bookmarkRootNode)) + QMessageBox::critical(0, tr("Export error"), tr("error saving bookmarks")); +} + +RemoveBookmarksCommand::RemoveBookmarksCommand(BookmarksManager *m_bookmarkManagaer, BookmarkNode *parent, int row) + : QUndoCommand(BookmarksManager::tr("Remove Bookmark")) + , m_row(row) + , m_bookmarkManagaer(m_bookmarkManagaer) + , m_node(parent->children().value(row)) + , m_parent(parent) + , m_done(false) +{ +} + +RemoveBookmarksCommand::~RemoveBookmarksCommand() +{ + if (m_done && !m_node->parent()) { + delete m_node; + } +} + +void RemoveBookmarksCommand::undo() +{ + m_parent->add(m_node, m_row); + emit m_bookmarkManagaer->entryAdded(m_node); + m_done = false; +} + +void RemoveBookmarksCommand::redo() +{ + m_parent->remove(m_node); + emit m_bookmarkManagaer->entryRemoved(m_parent, m_row, m_node); + m_done = true; +} + +InsertBookmarksCommand::InsertBookmarksCommand(BookmarksManager *m_bookmarkManagaer, + BookmarkNode *parent, BookmarkNode *node, int row) + : RemoveBookmarksCommand(m_bookmarkManagaer, parent, row) +{ + setText(BookmarksManager::tr("Insert Bookmark")); + m_node = node; +} + +ChangeBookmarkCommand::ChangeBookmarkCommand(BookmarksManager *m_bookmarkManagaer, BookmarkNode *node, + const QString &newValue, bool title) + : QUndoCommand() + , m_bookmarkManagaer(m_bookmarkManagaer) + , m_title(title) + , m_newValue(newValue) + , m_node(node) +{ + if (m_title) { + m_oldValue = m_node->title; + setText(BookmarksManager::tr("Name Change")); + } else { + m_oldValue = m_node->url; + setText(BookmarksManager::tr("Address Change")); + } +} + +void ChangeBookmarkCommand::undo() +{ + if (m_title) + m_node->title = m_oldValue; + else + m_node->url = m_oldValue; + emit m_bookmarkManagaer->entryChanged(m_node); +} + +void ChangeBookmarkCommand::redo() +{ + if (m_title) + m_node->title = m_newValue; + else + m_node->url = m_newValue; + emit m_bookmarkManagaer->entryChanged(m_node); +} + +BookmarksModel::BookmarksModel(BookmarksManager *bookmarkManager, QObject *parent) + : QAbstractItemModel(parent) + , m_endMacro(false) + , m_bookmarksManager(bookmarkManager) +{ + connect(bookmarkManager, SIGNAL(entryAdded(BookmarkNode *)), + this, SLOT(entryAdded(BookmarkNode *))); + connect(bookmarkManager, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), + this, SLOT(entryRemoved(BookmarkNode *, int, BookmarkNode *))); + connect(bookmarkManager, SIGNAL(entryChanged(BookmarkNode *)), + this, SLOT(entryChanged(BookmarkNode *))); +} + +QModelIndex BookmarksModel::index(BookmarkNode *node) const +{ + BookmarkNode *parent = node->parent(); + if (!parent) + return QModelIndex(); + return createIndex(parent->children().indexOf(node), 0, node); +} + +void BookmarksModel::entryAdded(BookmarkNode *item) +{ + Q_ASSERT(item && item->parent()); + int row = item->parent()->children().indexOf(item); + BookmarkNode *parent = item->parent(); + // item was already added so remove beore beginInsertRows is called + parent->remove(item); + beginInsertRows(index(parent), row, row); + parent->add(item, row); + endInsertRows(); +} + +void BookmarksModel::entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item) +{ + // item was already removed, re-add so beginRemoveRows works + parent->add(item, row); + beginRemoveRows(index(parent), row, row); + parent->remove(item); + endRemoveRows(); +} + +void BookmarksModel::entryChanged(BookmarkNode *item) +{ + QModelIndex idx = index(item); + emit dataChanged(idx, idx); +} + +bool BookmarksModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (row < 0 || count <= 0 || row + count > rowCount(parent)) + return false; + + BookmarkNode *bookmarkNode = node(parent); + for (int i = row + count - 1; i >= row; --i) { + BookmarkNode *node = bookmarkNode->children().at(i); + if (node == m_bookmarksManager->menu() + || node == m_bookmarksManager->toolbar()) + continue; + + m_bookmarksManager->removeBookmark(node); + } + if (m_endMacro) { + m_bookmarksManager->undoRedoStack()->endMacro(); + m_endMacro = false; + } + return true; +} + +QVariant BookmarksModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + switch (section) { + case 0: return tr("Title"); + case 1: return tr("Address"); + } + } + return QAbstractItemModel::headerData(section, orientation, role); +} + +QVariant BookmarksModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid() || index.model() != this) + return QVariant(); + + const BookmarkNode *bookmarkNode = node(index); + switch (role) { + case Qt::EditRole: + case Qt::DisplayRole: + if (bookmarkNode->type() == BookmarkNode::Separator) { + switch (index.column()) { + case 0: return QString(50, 0xB7); + case 1: return QString(); + } + } + + switch (index.column()) { + case 0: return bookmarkNode->title; + case 1: return bookmarkNode->url; + } + break; + case BookmarksModel::UrlRole: + return QUrl(bookmarkNode->url); + break; + case BookmarksModel::UrlStringRole: + return bookmarkNode->url; + break; + case BookmarksModel::TypeRole: + return bookmarkNode->type(); + break; + case BookmarksModel::SeparatorRole: + return (bookmarkNode->type() == BookmarkNode::Separator); + break; + case Qt::DecorationRole: + if (index.column() == 0) { + if (bookmarkNode->type() == BookmarkNode::Folder) + return QApplication::style()->standardIcon(QStyle::SP_DirIcon); + return BrowserApplication::instance()->icon(bookmarkNode->url); + } + } + + return QVariant(); +} + +int BookmarksModel::columnCount(const QModelIndex &parent) const +{ + return (parent.column() > 0) ? 0 : 2; +} + +int BookmarksModel::rowCount(const QModelIndex &parent) const +{ + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + return m_bookmarksManager->bookmarks()->children().count(); + + const BookmarkNode *item = static_cast(parent.internalPointer()); + return item->children().count(); +} + +QModelIndex BookmarksModel::index(int row, int column, const QModelIndex &parent) const +{ + if (row < 0 || column < 0 || row >= rowCount(parent) || column >= columnCount(parent)) + return QModelIndex(); + + // get the parent node + BookmarkNode *parentNode = node(parent); + return createIndex(row, column, parentNode->children().at(row)); +} + +QModelIndex BookmarksModel::parent(const QModelIndex &index) const +{ + if (!index.isValid()) + return QModelIndex(); + + BookmarkNode *itemNode = node(index); + BookmarkNode *parentNode = (itemNode ? itemNode->parent() : 0); + if (!parentNode || parentNode == m_bookmarksManager->bookmarks()) + return QModelIndex(); + + // get the parent's row + BookmarkNode *grandParentNode = parentNode->parent(); + int parentRow = grandParentNode->children().indexOf(parentNode); + Q_ASSERT(parentRow >= 0); + return createIndex(parentRow, 0, parentNode); +} + +bool BookmarksModel::hasChildren(const QModelIndex &parent) const +{ + if (!parent.isValid()) + return true; + const BookmarkNode *parentNode = node(parent); + return (parentNode->type() == BookmarkNode::Folder); +} + +Qt::ItemFlags BookmarksModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + + Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; + + BookmarkNode *bookmarkNode = node(index); + + if (bookmarkNode != m_bookmarksManager->menu() + && bookmarkNode != m_bookmarksManager->toolbar()) { + flags |= Qt::ItemIsDragEnabled; + if (bookmarkNode->type() != BookmarkNode::Separator) + flags |= Qt::ItemIsEditable; + } + if (hasChildren(index)) + flags |= Qt::ItemIsDropEnabled; + return flags; +} + +Qt::DropActions BookmarksModel::supportedDropActions () const +{ + return Qt::CopyAction | Qt::MoveAction; +} + +#define MIMETYPE QLatin1String("application/bookmarks.xbel") + +QStringList BookmarksModel::mimeTypes() const +{ + QStringList types; + types << MIMETYPE; + return types; +} + +QMimeData *BookmarksModel::mimeData(const QModelIndexList &indexes) const +{ + QMimeData *mimeData = new QMimeData(); + QByteArray data; + QDataStream stream(&data, QIODevice::WriteOnly); + foreach (QModelIndex index, indexes) { + if (index.column() != 0 || !index.isValid()) + continue; + QByteArray encodedData; + QBuffer buffer(&encodedData); + buffer.open(QBuffer::ReadWrite); + XbelWriter writer; + const BookmarkNode *parentNode = node(index); + writer.write(&buffer, parentNode); + stream << encodedData; + } + mimeData->setData(MIMETYPE, data); + return mimeData; +} + +bool BookmarksModel::dropMimeData(const QMimeData *data, + Qt::DropAction action, int row, int column, const QModelIndex &parent) +{ + if (action == Qt::IgnoreAction) + return true; + + if (!data->hasFormat(MIMETYPE) + || column > 0) + return false; + + QByteArray ba = data->data(MIMETYPE); + QDataStream stream(&ba, QIODevice::ReadOnly); + if (stream.atEnd()) + return false; + + QUndoStack *undoStack = m_bookmarksManager->undoRedoStack(); + undoStack->beginMacro(QLatin1String("Move Bookmarks")); + + while (!stream.atEnd()) { + QByteArray encodedData; + stream >> encodedData; + QBuffer buffer(&encodedData); + buffer.open(QBuffer::ReadOnly); + + XbelReader reader; + BookmarkNode *rootNode = reader.read(&buffer); + QList children = rootNode->children(); + for (int i = 0; i < children.count(); ++i) { + BookmarkNode *bookmarkNode = children.at(i); + rootNode->remove(bookmarkNode); + row = qMax(0, row); + BookmarkNode *parentNode = node(parent); + m_bookmarksManager->addBookmark(parentNode, bookmarkNode, row); + m_endMacro = true; + } + delete rootNode; + } + return true; +} + +bool BookmarksModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid() || (flags(index) & Qt::ItemIsEditable) == 0) + return false; + + BookmarkNode *item = node(index); + + switch (role) { + case Qt::EditRole: + case Qt::DisplayRole: + if (index.column() == 0) { + m_bookmarksManager->setTitle(item, value.toString()); + break; + } + if (index.column() == 1) { + m_bookmarksManager->setUrl(item, value.toString()); + break; + } + return false; + case BookmarksModel::UrlRole: + m_bookmarksManager->setUrl(item, value.toUrl().toString()); + break; + case BookmarksModel::UrlStringRole: + m_bookmarksManager->setUrl(item, value.toString()); + break; + default: + break; + return false; + } + + return true; +} + +BookmarkNode *BookmarksModel::node(const QModelIndex &index) const +{ + BookmarkNode *itemNode = static_cast(index.internalPointer()); + if (!itemNode) + return m_bookmarksManager->bookmarks(); + return itemNode; +} + + +AddBookmarkProxyModel::AddBookmarkProxyModel(QObject *parent) + : QSortFilterProxyModel(parent) +{ +} + +int AddBookmarkProxyModel::columnCount(const QModelIndex &parent) const +{ + return qMin(1, QSortFilterProxyModel::columnCount(parent)); +} + +bool AddBookmarkProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); + return sourceModel()->hasChildren(idx); +} + +AddBookmarkDialog::AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent, BookmarksManager *bookmarkManager) + : QDialog(parent) + , m_url(url) + , m_bookmarksManager(bookmarkManager) +{ + setWindowFlags(Qt::Sheet); + if (!m_bookmarksManager) + m_bookmarksManager = BrowserApplication::bookmarksManager(); + setupUi(this); + QTreeView *view = new QTreeView(this); + m_proxyModel = new AddBookmarkProxyModel(this); + BookmarksModel *model = m_bookmarksManager->bookmarksModel(); + m_proxyModel->setSourceModel(model); + view->setModel(m_proxyModel); + view->expandAll(); + view->header()->setStretchLastSection(true); + view->header()->hide(); + view->setItemsExpandable(false); + view->setRootIsDecorated(false); + view->setIndentation(10); + location->setModel(m_proxyModel); + view->show(); + location->setView(view); + BookmarkNode *menu = m_bookmarksManager->menu(); + QModelIndex idx = m_proxyModel->mapFromSource(model->index(menu)); + view->setCurrentIndex(idx); + location->setCurrentIndex(idx.row()); + name->setText(title); +} + +void AddBookmarkDialog::accept() +{ + QModelIndex index = location->view()->currentIndex(); + index = m_proxyModel->mapToSource(index); + if (!index.isValid()) + index = m_bookmarksManager->bookmarksModel()->index(0, 0); + BookmarkNode *parent = m_bookmarksManager->bookmarksModel()->node(index); + BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark); + bookmark->url = m_url; + bookmark->title = name->text(); + m_bookmarksManager->addBookmark(parent, bookmark); + QDialog::accept(); +} + +BookmarksMenu::BookmarksMenu(QWidget *parent) + : ModelMenu(parent) + , m_bookmarksManager(0) +{ + connect(this, SIGNAL(activated(const QModelIndex &)), + this, SLOT(activated(const QModelIndex &))); + setMaxRows(-1); + setHoverRole(BookmarksModel::UrlStringRole); + setSeparatorRole(BookmarksModel::SeparatorRole); +} + +void BookmarksMenu::activated(const QModelIndex &index) +{ + emit openUrl(index.data(BookmarksModel::UrlRole).toUrl()); +} + +bool BookmarksMenu::prePopulated() +{ + m_bookmarksManager = BrowserApplication::bookmarksManager(); + setModel(m_bookmarksManager->bookmarksModel()); + setRootIndex(m_bookmarksManager->bookmarksModel()->index(1, 0)); + // initial actions + for (int i = 0; i < m_initialActions.count(); ++i) + addAction(m_initialActions.at(i)); + if (!m_initialActions.isEmpty()) + addSeparator(); + createMenu(model()->index(0, 0), 1, this); + return true; +} + +void BookmarksMenu::setInitialActions(QList actions) +{ + m_initialActions = actions; + for (int i = 0; i < m_initialActions.count(); ++i) + addAction(m_initialActions.at(i)); +} + +BookmarksDialog::BookmarksDialog(QWidget *parent, BookmarksManager *manager) + : QDialog(parent) +{ + m_bookmarksManager = manager; + if (!m_bookmarksManager) + m_bookmarksManager = BrowserApplication::bookmarksManager(); + setupUi(this); + + tree->setUniformRowHeights(true); + tree->setSelectionBehavior(QAbstractItemView::SelectRows); + tree->setSelectionMode(QAbstractItemView::ContiguousSelection); + tree->setTextElideMode(Qt::ElideMiddle); + m_bookmarksModel = m_bookmarksManager->bookmarksModel(); + m_proxyModel = new TreeProxyModel(this); + connect(search, SIGNAL(textChanged(QString)), + m_proxyModel, SLOT(setFilterFixedString(QString))); + connect(removeButton, SIGNAL(clicked()), tree, SLOT(removeOne())); + m_proxyModel->setSourceModel(m_bookmarksModel); + tree->setModel(m_proxyModel); + tree->setDragDropMode(QAbstractItemView::InternalMove); + tree->setExpanded(m_proxyModel->index(0, 0), true); + tree->setAlternatingRowColors(true); + QFontMetrics fm(font()); + int header = fm.width(QLatin1Char('m')) * 40; + tree->header()->resizeSection(0, header); + tree->header()->setStretchLastSection(true); + connect(tree, SIGNAL(activated(const QModelIndex&)), + this, SLOT(open())); + tree->setContextMenuPolicy(Qt::CustomContextMenu); + connect(tree, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(customContextMenuRequested(const QPoint &))); + connect(addFolderButton, SIGNAL(clicked()), + this, SLOT(newFolder())); + expandNodes(m_bookmarksManager->bookmarks()); + setAttribute(Qt::WA_DeleteOnClose); +} + +BookmarksDialog::~BookmarksDialog() +{ + if (saveExpandedNodes(tree->rootIndex())) + m_bookmarksManager->changeExpanded(); +} + +bool BookmarksDialog::saveExpandedNodes(const QModelIndex &parent) +{ + bool changed = false; + for (int i = 0; i < m_proxyModel->rowCount(parent); ++i) { + QModelIndex child = m_proxyModel->index(i, 0, parent); + QModelIndex sourceIndex = m_proxyModel->mapToSource(child); + BookmarkNode *childNode = m_bookmarksModel->node(sourceIndex); + bool wasExpanded = childNode->expanded; + if (tree->isExpanded(child)) { + childNode->expanded = true; + changed |= saveExpandedNodes(child); + } else { + childNode->expanded = false; + } + changed |= (wasExpanded != childNode->expanded); + } + return changed; +} + +void BookmarksDialog::expandNodes(BookmarkNode *node) +{ + for (int i = 0; i < node->children().count(); ++i) { + BookmarkNode *childNode = node->children()[i]; + if (childNode->expanded) { + QModelIndex idx = m_bookmarksModel->index(childNode); + idx = m_proxyModel->mapFromSource(idx); + tree->setExpanded(idx, true); + expandNodes(childNode); + } + } +} + +void BookmarksDialog::customContextMenuRequested(const QPoint &pos) +{ + QMenu menu; + QModelIndex index = tree->indexAt(pos); + index = index.sibling(index.row(), 0); + if (index.isValid() && !tree->model()->hasChildren(index)) { + menu.addAction(tr("Open"), this, SLOT(open())); + menu.addSeparator(); + } + menu.addAction(tr("Delete"), tree, SLOT(removeOne())); + menu.exec(QCursor::pos()); +} + +void BookmarksDialog::open() +{ + QModelIndex index = tree->currentIndex(); + if (!index.parent().isValid()) + return; + emit openUrl(index.sibling(index.row(), 1).data(BookmarksModel::UrlRole).toUrl()); +} + +void BookmarksDialog::newFolder() +{ + QModelIndex currentIndex = tree->currentIndex(); + QModelIndex idx = currentIndex; + if (idx.isValid() && !idx.model()->hasChildren(idx)) + idx = idx.parent(); + if (!idx.isValid()) + idx = tree->rootIndex(); + idx = m_proxyModel->mapToSource(idx); + BookmarkNode *parent = m_bookmarksManager->bookmarksModel()->node(idx); + BookmarkNode *node = new BookmarkNode(BookmarkNode::Folder); + node->title = tr("New Folder"); + m_bookmarksManager->addBookmark(parent, node, currentIndex.row() + 1); +} + +BookmarksToolBar::BookmarksToolBar(BookmarksModel *model, QWidget *parent) + : QToolBar(tr("Bookmark"), parent) + , m_bookmarksModel(model) +{ + connect(this, SIGNAL(actionTriggered(QAction*)), this, SLOT(triggered(QAction*))); + setRootIndex(model->index(0, 0)); + connect(m_bookmarksModel, SIGNAL(modelReset()), this, SLOT(build())); + connect(m_bookmarksModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(build())); + connect(m_bookmarksModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(build())); + connect(m_bookmarksModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(build())); + setAcceptDrops(true); +} + +void BookmarksToolBar::dragEnterEvent(QDragEnterEvent *event) +{ + const QMimeData *mimeData = event->mimeData(); + if (mimeData->hasUrls()) + event->acceptProposedAction(); + QToolBar::dragEnterEvent(event); +} + +void BookmarksToolBar::dropEvent(QDropEvent *event) +{ + const QMimeData *mimeData = event->mimeData(); + if (mimeData->hasUrls() && mimeData->hasText()) { + QList urls = mimeData->urls(); + QAction *action = actionAt(event->pos()); + QString dropText; + if (action) + dropText = action->text(); + int row = -1; + QModelIndex parentIndex = m_root; + for (int i = 0; i < m_bookmarksModel->rowCount(m_root); ++i) { + QModelIndex idx = m_bookmarksModel->index(i, 0, m_root); + QString title = idx.data().toString(); + if (title == dropText) { + row = i; + if (m_bookmarksModel->hasChildren(idx)) { + parentIndex = idx; + row = -1; + } + break; + } + } + BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark); + bookmark->url = urls.at(0).toString(); + bookmark->title = mimeData->text(); + + BookmarkNode *parent = m_bookmarksModel->node(parentIndex); + BookmarksManager *bookmarksManager = m_bookmarksModel->bookmarksManager(); + bookmarksManager->addBookmark(parent, bookmark, row); + event->acceptProposedAction(); + } + QToolBar::dropEvent(event); +} + + +void BookmarksToolBar::setRootIndex(const QModelIndex &index) +{ + m_root = index; + build(); +} + +QModelIndex BookmarksToolBar::rootIndex() const +{ + return m_root; +} + +void BookmarksToolBar::build() +{ + clear(); + for (int i = 0; i < m_bookmarksModel->rowCount(m_root); ++i) { + QModelIndex idx = m_bookmarksModel->index(i, 0, m_root); + if (m_bookmarksModel->hasChildren(idx)) { + QToolButton *button = new QToolButton(this); + button->setPopupMode(QToolButton::InstantPopup); + button->setArrowType(Qt::DownArrow); + button->setText(idx.data().toString()); + ModelMenu *menu = new ModelMenu(this); + connect(menu, SIGNAL(activated(const QModelIndex &)), + this, SLOT(activated(const QModelIndex &))); + menu->setModel(m_bookmarksModel); + menu->setRootIndex(idx); + menu->addAction(new QAction(menu)); + button->setMenu(menu); + button->setToolButtonStyle(Qt::ToolButtonTextOnly); + QAction *a = addWidget(button); + a->setText(idx.data().toString()); + } else { + QAction *action = addAction(idx.data().toString()); + action->setData(idx.data(BookmarksModel::UrlRole)); + } + } +} + +void BookmarksToolBar::triggered(QAction *action) +{ + QVariant v = action->data(); + if (v.canConvert()) { + emit openUrl(v.toUrl()); + } +} + +void BookmarksToolBar::activated(const QModelIndex &index) +{ + emit openUrl(index.data(BookmarksModel::UrlRole).toUrl()); +} + diff --git a/src/bookmarks.h b/src/bookmarks.h new file mode 100644 index 00000000..768efd53 --- /dev/null +++ b/src/bookmarks.h @@ -0,0 +1,306 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef BOOKMARKS_H +#define BOOKMARKS_H + +#include +#include + +#include + +/*! + Bookmark manager, owner of the bookmarks, loads, saves and basic tasks + */ +class AutoSaver; +class BookmarkNode; +class BookmarksModel; +class BookmarksManager : public QObject +{ + Q_OBJECT + +signals: + void entryAdded(BookmarkNode *item); + void entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item); + void entryChanged(BookmarkNode *item); + +public: + BookmarksManager(QObject *parent = 0); + ~BookmarksManager(); + + void addBookmark(BookmarkNode *parent, BookmarkNode *node, int row = -1); + void removeBookmark(BookmarkNode *node); + void setTitle(BookmarkNode *node, const QString &newTitle); + void setUrl(BookmarkNode *node, const QString &newUrl); + void changeExpanded(); + + BookmarkNode *bookmarks(); + BookmarkNode *menu(); + BookmarkNode *toolbar(); + + BookmarksModel *bookmarksModel(); + QUndoStack *undoRedoStack() { return &m_commands; }; + +public slots: + void importBookmarks(); + void exportBookmarks(); + +private slots: + void save() const; + +private: + void load(); + + bool m_loaded; + AutoSaver *m_saveTimer; + BookmarkNode *m_bookmarkRootNode; + BookmarksModel *m_bookmarkModel; + QUndoStack m_commands; + + friend class RemoveBookmarksCommand; + friend class ChangeBookmarkCommand; +}; + +class RemoveBookmarksCommand : public QUndoCommand +{ + +public: + RemoveBookmarksCommand(BookmarksManager *m_bookmarkManagaer, BookmarkNode *parent, int row); + ~RemoveBookmarksCommand(); + void undo(); + void redo(); + +protected: + int m_row; + BookmarksManager *m_bookmarkManagaer; + BookmarkNode *m_node; + BookmarkNode *m_parent; + bool m_done; +}; + +class InsertBookmarksCommand : public RemoveBookmarksCommand +{ + +public: + InsertBookmarksCommand(BookmarksManager *m_bookmarkManagaer, + BookmarkNode *parent, BookmarkNode *node, int row); + void undo() { RemoveBookmarksCommand::redo(); } + void redo() { RemoveBookmarksCommand::undo(); } + +}; + +class ChangeBookmarkCommand : public QUndoCommand +{ + +public: + ChangeBookmarkCommand(BookmarksManager *m_bookmarkManagaer, + BookmarkNode *node, const QString &newValue, bool title); + void undo(); + void redo(); + +private: + BookmarksManager *m_bookmarkManagaer; + bool m_title; + QString m_oldValue; + QString m_newValue; + BookmarkNode *m_node; +}; + +/*! + BookmarksModel is a QAbstractItemModel wrapper around the BookmarkManager + */ +#include +class BookmarksModel : public QAbstractItemModel +{ + Q_OBJECT + +public slots: + void entryAdded(BookmarkNode *item); + void entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item); + void entryChanged(BookmarkNode *item); + +public: + enum Roles { + TypeRole = Qt::UserRole + 1, + UrlRole = Qt::UserRole + 2, + UrlStringRole = Qt::UserRole + 3, + SeparatorRole = Qt::UserRole + 4 + }; + + BookmarksModel(BookmarksManager *bookmarkManager, QObject *parent = 0); + inline BookmarksManager *bookmarksManager() const { return m_bookmarksManager; } + + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; + QModelIndex parent(const QModelIndex& index= QModelIndex()) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + Qt::DropActions supportedDropActions () const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + QMimeData *mimeData(const QModelIndexList &indexes) const; + QStringList mimeTypes() const; + bool dropMimeData(const QMimeData *data, + Qt::DropAction action, int row, int column, const QModelIndex &parent); + bool hasChildren(const QModelIndex &parent = QModelIndex()) const; + + BookmarkNode *node(const QModelIndex &index) const; + QModelIndex index(BookmarkNode *node) const; + +private: + + bool m_endMacro; + BookmarksManager *m_bookmarksManager; +}; + +// Menu that is dynamically populated from the bookmarks +#include "modelmenu.h" +class BookmarksMenu : public ModelMenu +{ + Q_OBJECT + +signals: + void openUrl(const QUrl &url); + +public: + BookmarksMenu(QWidget *parent = 0); + void setInitialActions(QList actions); + +protected: + bool prePopulated(); + +private slots: + void activated(const QModelIndex &index); + +private: + BookmarksManager *m_bookmarksManager; + QList m_initialActions; +}; + +/* + Proxy model that filters out the bookmarks so only the folders + are left behind. Used in the add bookmark dialog combobox. + */ +#include +class AddBookmarkProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT +public: + AddBookmarkProxyModel(QObject * parent = 0); + int columnCount(const QModelIndex & parent = QModelIndex()) const; + +protected: + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; +}; + +/*! + Add bookmark dialog + */ +#include "ui_addbookmarkdialog.h" +class AddBookmarkDialog : public QDialog, public Ui_AddBookmarkDialog +{ + Q_OBJECT + +public: + AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent = 0, BookmarksManager *bookmarkManager = 0); + +private slots: + void accept(); + +private: + QString m_url; + BookmarksManager *m_bookmarksManager; + AddBookmarkProxyModel *m_proxyModel; +}; + +#include "ui_bookmarks.h" +class TreeProxyModel; +class BookmarksDialog : public QDialog, public Ui_BookmarksDialog +{ + Q_OBJECT + +signals: + void openUrl(const QUrl &url); + +public: + BookmarksDialog(QWidget *parent = 0, BookmarksManager *manager = 0); + ~BookmarksDialog(); + +private slots: + void customContextMenuRequested(const QPoint &pos); + void open(); + void newFolder(); + +private: + void expandNodes(BookmarkNode *node); + bool saveExpandedNodes(const QModelIndex &parent); + + BookmarksManager *m_bookmarksManager; + BookmarksModel *m_bookmarksModel; + TreeProxyModel *m_proxyModel; +}; + +#include +class BookmarksToolBar : public QToolBar +{ + Q_OBJECT + +signals: + void openUrl(const QUrl &url); + +public: + BookmarksToolBar(BookmarksModel *model, QWidget *parent = 0); + void setRootIndex(const QModelIndex &index); + QModelIndex rootIndex() const; + +protected: + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + +private slots: + void triggered(QAction *action); + void activated(const QModelIndex &index); + void build(); + +private: + BookmarksModel *m_bookmarksModel; + QPersistentModelIndex m_root; +}; + +#endif // BOOKMARKS_H diff --git a/src/bookmarks.ui b/src/bookmarks.ui new file mode 100644 index 00000000..c893e941 --- /dev/null +++ b/src/bookmarks.ui @@ -0,0 +1,106 @@ + + BookmarksDialog + + + + 0 + 0 + 758 + 450 + + + + Bookmarks + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + + + &Remove + + + + + + + Add Folder + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + + SearchLineEdit + QLineEdit +
searchlineedit.h
+
+ + EditTreeView + QTreeView +
edittreeview.h
+
+
+ + + + buttonBox + accepted() + BookmarksDialog + accept() + + + 472 + 329 + + + 461 + 356 + + + + +
diff --git a/src/browser.icns b/src/browser.icns new file mode 100644 index 00000000..8cc82ba9 Binary files /dev/null and b/src/browser.icns differ diff --git a/src/browser.ico b/src/browser.ico new file mode 100644 index 00000000..f15627a1 Binary files /dev/null and b/src/browser.ico differ diff --git a/src/browser.pro b/src/browser.pro new file mode 100644 index 00000000..38ef03b5 --- /dev/null +++ b/src/browser.pro @@ -0,0 +1,87 @@ +TEMPLATE = app +TARGET = browser +QT += webkit network + +CONFIG += qt warn_on +contains(QT_BUILD_PARTS, tools): CONFIG += uitools +else: DEFINES += QT_NO_UITOOLS + +FORMS += \ + addbookmarkdialog.ui \ + bookmarks.ui \ + cookies.ui \ + cookiesexceptions.ui \ + downloaditem.ui \ + downloads.ui \ + history.ui \ + passworddialog.ui \ + proxy.ui \ + settings.ui + +HEADERS += \ + autosaver.h \ + bookmarks.h \ + browserapplication.h \ + browsermainwindow.h \ + chasewidget.h \ + cookiejar.h \ + downloadmanager.h \ + edittableview.h \ + edittreeview.h \ + history.h \ + modelmenu.h \ + networkaccessmanager.h \ + searchlineedit.h \ + settings.h \ + squeezelabel.h \ + tabwidget.h \ + toolbarsearch.h \ + urllineedit.h \ + webview.h \ + xbel.h + +SOURCES += \ + autosaver.cpp \ + bookmarks.cpp \ + browserapplication.cpp \ + browsermainwindow.cpp \ + chasewidget.cpp \ + cookiejar.cpp \ + downloadmanager.cpp \ + edittableview.cpp \ + edittreeview.cpp \ + history.cpp \ + modelmenu.cpp \ + networkaccessmanager.cpp \ + searchlineedit.cpp \ + settings.cpp \ + squeezelabel.cpp \ + tabwidget.cpp \ + toolbarsearch.cpp \ + urllineedit.cpp \ + webview.cpp \ + xbel.cpp \ + main.cpp + +RESOURCES += data/data.qrc htmls/htmls.qrc + +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +win32 { + RC_FILE = browser.rc +} + +mac { + ICON = browser.icns + QMAKE_INFO_PLIST = Info_mac.plist + TARGET = Browser +} + +# install +target.path = $$[QT_INSTALL_DEMOS]/browser +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.plist *.icns *.ico *.rc *.pro *.html *.doc images htmls +sources.path = $$[QT_INSTALL_DEMOS]/browser +INSTALLS += target sources diff --git a/src/browser.rc b/src/browser.rc new file mode 100644 index 00000000..89a237ce --- /dev/null +++ b/src/browser.rc @@ -0,0 +1,2 @@ +IDI_ICON1 ICON DISCARDABLE "browser.ico" + diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp new file mode 100644 index 00000000..f904ea1c --- /dev/null +++ b/src/browserapplication.cpp @@ -0,0 +1,439 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "browserapplication.h" + +#include "bookmarks.h" +#include "browsermainwindow.h" +#include "cookiejar.h" +#include "downloadmanager.h" +#include "history.h" +#include "networkaccessmanager.h" +#include "tabwidget.h" +#include "webview.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include + +#include + +DownloadManager *BrowserApplication::s_downloadManager = 0; +HistoryManager *BrowserApplication::s_historyManager = 0; +NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0; +BookmarksManager *BrowserApplication::s_bookmarksManager = 0; + +BrowserApplication::BrowserApplication(int &argc, char **argv) + : QApplication(argc, argv) + , m_localServer(0) +{ + QCoreApplication::setOrganizationName(QLatin1String("Trolltech")); + QCoreApplication::setApplicationName(QLatin1String("demobrowser")); + QCoreApplication::setApplicationVersion(QLatin1String("0.1")); +#ifdef Q_WS_QWS + // Use a different server name for QWS so we can run an X11 + // browser and a QWS browser in parallel on the same machine for + // debugging + QString serverName = QCoreApplication::applicationName() + QLatin1String("_qws"); +#else + QString serverName = QCoreApplication::applicationName(); +#endif + QLocalSocket socket; + socket.connectToServer(serverName); + if (socket.waitForConnected(500)) { + QTextStream stream(&socket); + QStringList args = QCoreApplication::arguments(); + if (args.count() > 1) + stream << args.last(); + else + stream << QString(); + stream.flush(); + socket.waitForBytesWritten(); + return; + } + +#if defined(Q_WS_MAC) + QApplication::setQuitOnLastWindowClosed(false); +#else + QApplication::setQuitOnLastWindowClosed(true); +#endif + + m_localServer = new QLocalServer(this); + connect(m_localServer, SIGNAL(newConnection()), + this, SLOT(newLocalSocketConnection())); + if (!m_localServer->listen(serverName)) { + if (m_localServer->serverError() == QAbstractSocket::AddressInUseError + && QFile::exists(m_localServer->serverName())) { + QFile::remove(m_localServer->serverName()); + m_localServer->listen(serverName); + } + } + + QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); + QString localSysName = QLocale::system().name(); + + installTranslator(QLatin1String("qt_") + localSysName); + + QSettings settings; + settings.beginGroup(QLatin1String("sessions")); + m_lastSession = settings.value(QLatin1String("lastSession")).toByteArray(); + settings.endGroup(); + +#if defined(Q_WS_MAC) + connect(this, SIGNAL(lastWindowClosed()), + this, SLOT(lastWindowClosed())); +#endif + + QTimer::singleShot(0, this, SLOT(postLaunch())); +} + +BrowserApplication::~BrowserApplication() +{ + delete s_downloadManager; + qDeleteAll(m_mainWindows); + delete s_networkAccessManager; + delete s_bookmarksManager; +} + +#if defined(Q_WS_MAC) +void BrowserApplication::lastWindowClosed() +{ + clean(); + BrowserMainWindow *mw = new BrowserMainWindow; + mw->slotHome(); + m_mainWindows.prepend(mw); +} +#endif + +BrowserApplication *BrowserApplication::instance() +{ + return (static_cast(QCoreApplication::instance())); +} + +#if defined(Q_WS_MAC) +#include +void BrowserApplication::quitBrowser() +{ + clean(); + int tabCount = 0; + for (int i = 0; i < m_mainWindows.count(); ++i) { + tabCount =+ m_mainWindows.at(i)->tabWidget()->count(); + } + + if (tabCount > 1) { + int ret = QMessageBox::warning(mainWindow(), QString(), + tr("There are %1 windows and %2 tabs open\n" + "Do you want to quit anyway?").arg(m_mainWindows.count()).arg(tabCount), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); + if (ret == QMessageBox::No) + return; + } + + exit(0); +} +#endif + +/*! + Any actions that can be delayed until the window is visible + */ +void BrowserApplication::postLaunch() +{ + QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + if (directory.isEmpty()) + directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); + QWebSettings::setIconDatabasePath(directory); + +// setWindowIcon(QIcon(QLatin1String(":browser.svg"))); // FIXME setICON + + loadSettings(); + + // newMainWindow() needs to be called in main() for this to happen + if (m_mainWindows.count() > 0) { + QStringList args = QCoreApplication::arguments(); + if (args.count() > 1) + mainWindow()->loadPage(args.last()); + else + mainWindow()->slotHome(); + } + BrowserApplication::historyManager(); +} + +void BrowserApplication::loadSettings() +{ + QSettings settings; + settings.beginGroup(QLatin1String("websettings")); + + QWebSettings *defaultSettings = QWebSettings::globalSettings(); + QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); + int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); + QFont standardFont = QFont(standardFontFamily, standardFontSize); + standardFont = qVariantValue(settings.value(QLatin1String("standardFont"), standardFont)); + defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); + + QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); + int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); + QFont fixedFont = QFont(fixedFontFamily, fixedFontSize); + fixedFont = qVariantValue(settings.value(QLatin1String("fixedFont"), fixedFont)); + defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); + + defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool()); + defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool()); + + QUrl url = settings.value(QLatin1String("userStyleSheet")).toUrl(); + defaultSettings->setUserStyleSheetUrl(url); + + settings.endGroup(); +} + +QList BrowserApplication::mainWindows() +{ + clean(); + QList list; + for (int i = 0; i < m_mainWindows.count(); ++i) + list.append(m_mainWindows.at(i)); + return list; +} + +void BrowserApplication::clean() +{ + // cleanup any deleted main windows first + for (int i = m_mainWindows.count() - 1; i >= 0; --i) + if (m_mainWindows.at(i).isNull()) + m_mainWindows.removeAt(i); +} + +void BrowserApplication::saveSession() +{ + QWebSettings *globalSettings = QWebSettings::globalSettings(); + if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + return; + + clean(); + + QSettings settings; + settings.beginGroup(QLatin1String("sessions")); + + QByteArray data; + QBuffer buffer(&data); + QDataStream stream(&buffer); + buffer.open(QIODevice::ReadWrite); + + stream << m_mainWindows.count(); + for (int i = 0; i < m_mainWindows.count(); ++i) + stream << m_mainWindows.at(i)->saveState(); + settings.setValue(QLatin1String("lastSession"), data); + settings.endGroup(); +} + +bool BrowserApplication::canRestoreSession() const +{ + return !m_lastSession.isEmpty(); +} + +void BrowserApplication::restoreLastSession() +{ + QList windows; + QBuffer buffer(&m_lastSession); + QDataStream stream(&buffer); + buffer.open(QIODevice::ReadOnly); + int windowCount; + stream >> windowCount; + for (int i = 0; i < windowCount; ++i) { + QByteArray windowState; + stream >> windowState; + windows.append(windowState); + } + for (int i = 0; i < windows.count(); ++i) { + BrowserMainWindow *newWindow = 0; + if (m_mainWindows.count() == 1 + && mainWindow()->tabWidget()->count() == 1 + && mainWindow()->currentTab()->url() == QUrl()) { + newWindow = mainWindow(); + } else { + newWindow = newMainWindow(); + } + newWindow->restoreState(windows.at(i)); + } +} + +bool BrowserApplication::isTheOnlyBrowser() const +{ + return (m_localServer != 0); +} + +void BrowserApplication::installTranslator(const QString &name) +{ + QTranslator *translator = new QTranslator(this); + translator->load(name, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + QApplication::installTranslator(translator); +} + +#if defined(Q_WS_MAC) +bool BrowserApplication::event(QEvent* event) +{ + switch (event->type()) { + case QEvent::ApplicationActivate: { + clean(); + if (!m_mainWindows.isEmpty()) { + BrowserMainWindow *mw = mainWindow(); + if (mw && !mw->isMinimized()) { + mainWindow()->show(); + } + return true; + } + } + case QEvent::FileOpen: + if (!m_mainWindows.isEmpty()) { + mainWindow()->loadPage(static_cast(event)->file()); + return true; + } + default: + break; + } + return QApplication::event(event); +} +#endif + +void BrowserApplication::openUrl(const QUrl &url) +{ + mainWindow()->loadPage(url.toString()); +} + +BrowserMainWindow *BrowserApplication::newMainWindow() +{ + BrowserMainWindow *browser = new BrowserMainWindow(); + m_mainWindows.prepend(browser); + browser->show(); + return browser; +} + +BrowserMainWindow *BrowserApplication::mainWindow() +{ + clean(); + if (m_mainWindows.isEmpty()) + newMainWindow(); + return m_mainWindows[0]; +} + +void BrowserApplication::newLocalSocketConnection() +{ + QLocalSocket *socket = m_localServer->nextPendingConnection(); + if (!socket) + return; + socket->waitForReadyRead(1000); + QTextStream stream(socket); + QString url; + stream >> url; + if (!url.isEmpty()) { + QSettings settings; + settings.beginGroup(QLatin1String("general")); + int openLinksIn = settings.value(QLatin1String("openLinksIn"), 0).toInt(); + settings.endGroup(); + if (openLinksIn == 1) + newMainWindow(); + else + mainWindow()->tabWidget()->newTab(); + openUrl(url); + } + delete socket; + mainWindow()->raise(); + mainWindow()->activateWindow(); +} + +CookieJar *BrowserApplication::cookieJar() +{ + return (CookieJar*)networkAccessManager()->cookieJar(); +} + +DownloadManager *BrowserApplication::downloadManager() +{ + if (!s_downloadManager) { + s_downloadManager = new DownloadManager(); + } + return s_downloadManager; +} + +NetworkAccessManager *BrowserApplication::networkAccessManager() +{ + if (!s_networkAccessManager) { + s_networkAccessManager = new NetworkAccessManager(); + s_networkAccessManager->setCookieJar(new CookieJar); + } + return s_networkAccessManager; +} + +HistoryManager *BrowserApplication::historyManager() +{ + if (!s_historyManager) { + s_historyManager = new HistoryManager(); + QWebHistoryInterface::setDefaultInterface(s_historyManager); + } + return s_historyManager; +} + +BookmarksManager *BrowserApplication::bookmarksManager() +{ + if (!s_bookmarksManager) { + s_bookmarksManager = new BookmarksManager; + } + return s_bookmarksManager; +} + +QIcon BrowserApplication::icon(const QUrl &url) const +{ + QIcon icon = QWebSettings::iconForUrl(url); + if (!icon.isNull()) + return icon.pixmap(16, 16); + if (m_defaultIcon.isNull()) + m_defaultIcon = QIcon(QLatin1String(":defaulticon.png")); + return m_defaultIcon.pixmap(16, 16); +} diff --git a/src/browserapplication.h b/src/browserapplication.h new file mode 100644 index 00000000..19d02a47 --- /dev/null +++ b/src/browserapplication.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef BROWSERAPPLICATION_H +#define BROWSERAPPLICATION_H + +#include + +#include +#include + +#include + +QT_BEGIN_NAMESPACE +class QLocalServer; +QT_END_NAMESPACE + +class BookmarksManager; +class BrowserMainWindow; +class CookieJar; +class DownloadManager; +class HistoryManager; +class NetworkAccessManager; +class BrowserApplication : public QApplication +{ + Q_OBJECT + +public: + BrowserApplication(int &argc, char **argv); + ~BrowserApplication(); + static BrowserApplication *instance(); + void loadSettings(); + + bool isTheOnlyBrowser() const; + BrowserMainWindow *mainWindow(); + QList mainWindows(); + QIcon icon(const QUrl &url) const; + + void saveSession(); + bool canRestoreSession() const; + + static HistoryManager *historyManager(); + static CookieJar *cookieJar(); + static DownloadManager *downloadManager(); + static NetworkAccessManager *networkAccessManager(); + static BookmarksManager *bookmarksManager(); + +#if defined(Q_WS_MAC) + bool event(QEvent *event); +#endif + +public slots: + BrowserMainWindow *newMainWindow(); + void restoreLastSession(); +#if defined(Q_WS_MAC) + void lastWindowClosed(); + void quitBrowser(); +#endif + +private slots: + void postLaunch(); + void openUrl(const QUrl &url); + void newLocalSocketConnection(); + +private: + void clean(); + void installTranslator(const QString &name); + + static HistoryManager *s_historyManager; + static DownloadManager *s_downloadManager; + static NetworkAccessManager *s_networkAccessManager; + static BookmarksManager *s_bookmarksManager; + + QList > m_mainWindows; + QLocalServer *m_localServer; + QByteArray m_lastSession; + mutable QIcon m_defaultIcon; +}; + +#endif // BROWSERAPPLICATION_H + diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp new file mode 100644 index 00000000..3d1617e4 --- /dev/null +++ b/src/browsermainwindow.cpp @@ -0,0 +1,969 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "browsermainwindow.h" + +#include "autosaver.h" +#include "bookmarks.h" +#include "browserapplication.h" +#include "chasewidget.h" +#include "downloadmanager.h" +#include "history.h" +#include "settings.h" +#include "tabwidget.h" +#include "toolbarsearch.h" +#include "ui_passworddialog.h" +#include "webview.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) + : QMainWindow(parent, flags) + , m_tabWidget(new TabWidget(this)) + , m_autoSaver(new AutoSaver(this)) + , m_historyBack(0) + , m_historyForward(0) + , m_stop(0) + , m_reload(0) +{ + setAttribute(Qt::WA_DeleteOnClose, true); + statusBar()->setSizeGripEnabled(true); + setupMenu(); + setupToolBar(); + + QWidget *centralWidget = new QWidget(this); + BookmarksModel *boomarksModel = BrowserApplication::bookmarksManager()->bookmarksModel(); + m_bookmarksToolbar = new BookmarksToolBar(boomarksModel, this); + connect(m_bookmarksToolbar, SIGNAL(openUrl(const QUrl&)), + m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(m_bookmarksToolbar->toggleViewAction(), SIGNAL(toggled(bool)), + this, SLOT(updateBookmarksToolbarActionText(bool))); + + QVBoxLayout *layout = new QVBoxLayout; + layout->setSpacing(0); + layout->setMargin(0); +#if defined(Q_WS_MAC) + layout->addWidget(m_bookmarksToolbar); + layout->addWidget(new QWidget); // <- OS X tab widget style bug +#else + addToolBarBreak(); + addToolBar(m_bookmarksToolbar); +#endif + layout->addWidget(m_tabWidget); + centralWidget->setLayout(layout); + setCentralWidget(centralWidget); + + connect(m_tabWidget, SIGNAL(loadPage(const QString &)), + this, SLOT(loadPage(const QString &))); + connect(m_tabWidget, SIGNAL(setCurrentTitle(const QString &)), + this, SLOT(slotUpdateWindowTitle(const QString &))); + connect(m_tabWidget, SIGNAL(showStatusBarMessage(const QString&)), + statusBar(), SLOT(showMessage(const QString&))); + connect(m_tabWidget, SIGNAL(linkHovered(const QString&)), + statusBar(), SLOT(showMessage(const QString&))); + connect(m_tabWidget, SIGNAL(loadProgress(int)), + this, SLOT(slotLoadProgress(int))); + connect(m_tabWidget, SIGNAL(tabsChanged()), + m_autoSaver, SLOT(changeOccurred())); + connect(m_tabWidget, SIGNAL(geometryChangeRequested(const QRect &)), + this, SLOT(geometryChangeRequested(const QRect &))); + connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)), + this, SLOT(printRequested(QWebFrame *))); + connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)), + menuBar(), SLOT(setVisible(bool))); + connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)), + statusBar(), SLOT(setVisible(bool))); + connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), + m_navigationBar, SLOT(setVisible(bool))); + connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), + m_bookmarksToolbar, SLOT(setVisible(bool))); +#if defined(Q_WS_MAC) + connect(m_tabWidget, SIGNAL(lastTabClosed()), + this, SLOT(close())); +#else + connect(m_tabWidget, SIGNAL(lastTabClosed()), + m_tabWidget, SLOT(newTab())); +#endif + + slotUpdateWindowTitle(); + loadDefaultState(); + m_tabWidget->newTab(); + + int size = m_tabWidget->lineEditStack()->sizeHint().height(); + m_navigationBar->setIconSize(QSize(size, size)); +} + +BrowserMainWindow::~BrowserMainWindow() +{ + m_autoSaver->changeOccurred(); + m_autoSaver->saveIfNeccessary(); +} + +void BrowserMainWindow::loadDefaultState() +{ + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); + restoreState(data); + settings.endGroup(); +} + +QSize BrowserMainWindow::sizeHint() const +{ + QRect desktopRect = QApplication::desktop()->screenGeometry(); + QSize size = desktopRect.size() * 0.9; + return size; +} + +void BrowserMainWindow::save() +{ + BrowserApplication::instance()->saveSession(); + + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + QByteArray data = saveState(false); + settings.setValue(QLatin1String("defaultState"), data); + settings.endGroup(); +} + +static const qint32 BrowserMainWindowMagic = 0xba; + +QByteArray BrowserMainWindow::saveState(bool withTabs) const +{ + int version = 2; + QByteArray data; + QDataStream stream(&data, QIODevice::WriteOnly); + + stream << qint32(BrowserMainWindowMagic); + stream << qint32(version); + + stream << size(); + stream << !m_navigationBar->isHidden(); + stream << !m_bookmarksToolbar->isHidden(); + stream << !statusBar()->isHidden(); + if (withTabs) + stream << tabWidget()->saveState(); + else + stream << QByteArray(); + return data; +} + +bool BrowserMainWindow::restoreState(const QByteArray &state) +{ + int version = 2; + QByteArray sd = state; + QDataStream stream(&sd, QIODevice::ReadOnly); + if (stream.atEnd()) + return false; + + qint32 marker; + qint32 v; + stream >> marker; + stream >> v; + if (marker != BrowserMainWindowMagic || v != version) + return false; + + QSize size; + bool showToolbar; + bool showBookmarksBar; + bool showStatusbar; + QByteArray tabState; + + stream >> size; + stream >> showToolbar; + stream >> showBookmarksBar; + stream >> showStatusbar; + stream >> tabState; + + resize(size); + + m_navigationBar->setVisible(showToolbar); + updateToolbarActionText(showToolbar); + + m_bookmarksToolbar->setVisible(showBookmarksBar); + updateBookmarksToolbarActionText(showBookmarksBar); + + statusBar()->setVisible(showStatusbar); + updateStatusbarActionText(showStatusbar); + + if (!tabWidget()->restoreState(tabState)) + return false; + + return true; +} + +void BrowserMainWindow::setupMenu() +{ + new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(slotSwapFocus())); + + // File + QMenu *fileMenu = menuBar()->addMenu(tr("&File")); + + fileMenu->addAction(tr("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New); + fileMenu->addAction(m_tabWidget->newTabAction()); + fileMenu->addAction(tr("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence::Open); + fileMenu->addAction(tr("Open &Location..."), this, + SLOT(slotSelectLineEdit()), QKeySequence(Qt::ControlModifier + Qt::Key_L)); + fileMenu->addSeparator(); + fileMenu->addAction(m_tabWidget->closeTabAction()); + fileMenu->addSeparator(); + fileMenu->addAction(tr("&Save As..."), this, + SLOT(slotFileSaveAs()), QKeySequence(QKeySequence::Save)); + fileMenu->addSeparator(); + BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); + fileMenu->addAction(tr("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); + fileMenu->addAction(tr("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); + fileMenu->addSeparator(); + fileMenu->addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview())); + fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print); + fileMenu->addSeparator(); + QAction *action = fileMenu->addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing())); + action->setCheckable(true); + fileMenu->addSeparator(); + +#if defined(Q_WS_MAC) + fileMenu->addAction(tr("&Quit"), BrowserApplication::instance(), SLOT(quitBrowser()), QKeySequence(Qt::CTRL | Qt::Key_Q)); +#else + fileMenu->addAction(tr("&Quit"), this, SLOT(close()), QKeySequence(Qt::CTRL | Qt::Key_Q)); +#endif + + // Edit + QMenu *editMenu = menuBar()->addMenu(tr("&Edit")); + QAction *m_undo = editMenu->addAction(tr("&Undo")); + m_undo->setShortcuts(QKeySequence::Undo); + m_tabWidget->addWebAction(m_undo, QWebPage::Undo); + QAction *m_redo = editMenu->addAction(tr("&Redo")); + m_redo->setShortcuts(QKeySequence::Redo); + m_tabWidget->addWebAction(m_redo, QWebPage::Redo); + editMenu->addSeparator(); + QAction *m_cut = editMenu->addAction(tr("Cu&t")); + m_cut->setShortcuts(QKeySequence::Cut); + m_tabWidget->addWebAction(m_cut, QWebPage::Cut); + QAction *m_copy = editMenu->addAction(tr("&Copy")); + m_copy->setShortcuts(QKeySequence::Copy); + m_tabWidget->addWebAction(m_copy, QWebPage::Copy); + QAction *m_paste = editMenu->addAction(tr("&Paste")); + m_paste->setShortcuts(QKeySequence::Paste); + m_tabWidget->addWebAction(m_paste, QWebPage::Paste); + editMenu->addSeparator(); + + QAction *m_find = editMenu->addAction(tr("&Find")); + m_find->setShortcuts(QKeySequence::Find); + connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); + new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); + + QAction *m_findNext = editMenu->addAction(tr("&Find Next")); + m_findNext->setShortcuts(QKeySequence::FindNext); + connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); + + QAction *m_findPrevious = editMenu->addAction(tr("&Find Previous")); + m_findPrevious->setShortcuts(QKeySequence::FindPrevious); + connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); + + editMenu->addSeparator(); + editMenu->addAction(tr("&Preferences"), this, SLOT(slotPreferences()), tr("Ctrl+,")); + + // View + QMenu *viewMenu = menuBar()->addMenu(tr("&View")); + + m_viewBookmarkBar = new QAction(this); + updateBookmarksToolbarActionText(true); + m_viewBookmarkBar->setShortcut(tr("Shift+Ctrl+B")); + connect(m_viewBookmarkBar, SIGNAL(triggered()), this, SLOT(slotViewBookmarksBar())); + viewMenu->addAction(m_viewBookmarkBar); + + m_viewToolbar = new QAction(this); + updateToolbarActionText(true); + m_viewToolbar->setShortcut(tr("Ctrl+|")); + connect(m_viewToolbar, SIGNAL(triggered()), this, SLOT(slotViewToolbar())); + viewMenu->addAction(m_viewToolbar); + + m_viewStatusbar = new QAction(this); + updateStatusbarActionText(true); + m_viewStatusbar->setShortcut(tr("Ctrl+/")); + connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); + viewMenu->addAction(m_viewStatusbar); + + viewMenu->addSeparator(); + + m_stop = viewMenu->addAction(tr("&Stop")); + QList shortcuts; + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); + shortcuts.append(Qt::Key_Escape); + m_stop->setShortcuts(shortcuts); + m_tabWidget->addWebAction(m_stop, QWebPage::Stop); + + m_reload = viewMenu->addAction(tr("Reload Page")); + m_reload->setShortcuts(QKeySequence::Refresh); + m_tabWidget->addWebAction(m_reload, QWebPage::Reload); + + viewMenu->addAction(tr("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); + viewMenu->addAction(tr("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); + viewMenu->addAction(tr("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); + + viewMenu->addSeparator(); + viewMenu->addAction(tr("Page S&ource"), this, SLOT(slotViewPageSource()), tr("Ctrl+Alt+U")); + QAction *a = viewMenu->addAction(tr("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); + a->setCheckable(true); + + // History + HistoryMenu *historyMenu = new HistoryMenu(this); + connect(historyMenu, SIGNAL(openUrl(const QUrl&)), + m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(historyMenu, SIGNAL(hovered(const QString&)), this, + SLOT(slotUpdateStatusbar(const QString&))); + historyMenu->setTitle(tr("Hi&story")); + menuBar()->addMenu(historyMenu); + QList historyActions; + + m_historyBack = new QAction(tr("Back"), this); + m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); + m_historyBack->setShortcuts(QKeySequence::Back); + m_historyBack->setIconVisibleInMenu(false); + + m_historyForward = new QAction(tr("Forward"), this); + m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); + m_historyForward->setShortcuts(QKeySequence::Forward); + m_historyForward->setIconVisibleInMenu(false); + + QAction *m_historyHome = new QAction(tr("Home"), this); + connect(m_historyHome, SIGNAL(triggered()), this, SLOT(slotHome())); + m_historyHome->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H)); + + m_restoreLastSession = new QAction(tr("Restore Last Session"), this); + connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); + m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); + + historyActions.append(m_historyBack); + historyActions.append(m_historyForward); + historyActions.append(m_historyHome); + historyActions.append(m_tabWidget->recentlyClosedTabsAction()); + historyActions.append(m_restoreLastSession); + historyMenu->setInitialActions(historyActions); + + // Bookmarks + BookmarksMenu *bookmarksMenu = new BookmarksMenu(this); + connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), + m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(bookmarksMenu, SIGNAL(hovered(const QString&)), + this, SLOT(slotUpdateStatusbar(const QString&))); + bookmarksMenu->setTitle(tr("&Bookmarks")); + menuBar()->addMenu(bookmarksMenu); + + QList bookmarksActions; + + QAction *showAllBookmarksAction = new QAction(tr("Show All Bookmarks"), this); + connect(showAllBookmarksAction, SIGNAL(triggered()), this, SLOT(slotShowBookmarksDialog())); + m_addBookmark = new QAction(QIcon(QLatin1String(":addbookmark.png")), tr("Add Bookmark..."), this); + m_addBookmark->setIconVisibleInMenu(false); + + connect(m_addBookmark, SIGNAL(triggered()), this, SLOT(slotAddBookmark())); + m_addBookmark->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D)); + + bookmarksActions.append(showAllBookmarksAction); + bookmarksActions.append(m_addBookmark); + bookmarksMenu->setInitialActions(bookmarksActions); + + // Window + m_windowMenu = menuBar()->addMenu(tr("&Window")); + connect(m_windowMenu, SIGNAL(aboutToShow()), + this, SLOT(slotAboutToShowWindowMenu())); + slotAboutToShowWindowMenu(); + + QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools")); + toolsMenu->addAction(tr("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence(tr("Ctrl+K", "Web Search"))); +#ifndef Q_CC_MINGW + a = toolsMenu->addAction(tr("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); + a->setCheckable(true); +#endif + + QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); + helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); + helpMenu->addAction(tr("About &Demo Browser"), this, SLOT(slotAboutApplication())); +} + +void BrowserMainWindow::setupToolBar() +{ + setUnifiedTitleAndToolBarOnMac(true); + m_navigationBar = addToolBar(tr("Navigation")); + connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), + this, SLOT(updateToolbarActionText(bool))); + + m_historyBack->setIcon(style()->standardIcon(QStyle::SP_ArrowBack, 0, this)); + m_historyBackMenu = new QMenu(this); + m_historyBack->setMenu(m_historyBackMenu); + connect(m_historyBackMenu, SIGNAL(aboutToShow()), + this, SLOT(slotAboutToShowBackMenu())); + connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), + this, SLOT(slotOpenActionUrl(QAction *))); + m_navigationBar->addAction(m_historyBack); + + m_historyForward->setIcon(style()->standardIcon(QStyle::SP_ArrowForward, 0, this)); + m_historyForwardMenu = new QMenu(this); + connect(m_historyForwardMenu, SIGNAL(aboutToShow()), + this, SLOT(slotAboutToShowForwardMenu())); + connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), + this, SLOT(slotOpenActionUrl(QAction *))); + m_historyForward->setMenu(m_historyForwardMenu); + m_navigationBar->addAction(m_historyForward); + + m_stopReload = new QAction(this); + m_reloadIcon = style()->standardIcon(QStyle::SP_BrowserReload); + m_stopReload->setIcon(m_reloadIcon); + + m_navigationBar->addAction(m_stopReload); + + m_navigationBar->addWidget(m_tabWidget->lineEditStack()); + + m_toolbarSearch = new ToolbarSearch(m_navigationBar); + m_navigationBar->addWidget(m_toolbarSearch); + connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); + + m_chaseWidget = new ChaseWidget(this); + m_navigationBar->addWidget(m_chaseWidget); +} + +void BrowserMainWindow::slotShowBookmarksDialog() +{ + BookmarksDialog *dialog = new BookmarksDialog(this); + connect(dialog, SIGNAL(openUrl(const QUrl&)), + m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + dialog->show(); +} + +void BrowserMainWindow::slotAddBookmark() +{ + WebView *webView = currentTab(); + QString url = webView->url().toString(); + QString title = webView->title(); + AddBookmarkDialog dialog(url, title); + dialog.exec(); +} + +void BrowserMainWindow::slotViewToolbar() +{ + if (m_navigationBar->isVisible()) { + updateToolbarActionText(false); + m_navigationBar->close(); + } else { + updateToolbarActionText(true); + m_navigationBar->show(); + } + m_autoSaver->changeOccurred(); +} + +void BrowserMainWindow::slotViewBookmarksBar() +{ + if (m_bookmarksToolbar->isVisible()) { + updateBookmarksToolbarActionText(false); + m_bookmarksToolbar->close(); + } else { + updateBookmarksToolbarActionText(true); + m_bookmarksToolbar->show(); + } + m_autoSaver->changeOccurred(); +} + +void BrowserMainWindow::updateStatusbarActionText(bool visible) +{ + m_viewStatusbar->setText(!visible ? tr("Show Status Bar") : tr("Hide Status Bar")); +} + +void BrowserMainWindow::updateToolbarActionText(bool visible) +{ + m_viewToolbar->setText(!visible ? tr("Show Toolbar") : tr("Hide Toolbar")); +} + +void BrowserMainWindow::updateBookmarksToolbarActionText(bool visible) +{ + m_viewBookmarkBar->setText(!visible ? tr("Show Bookmarks bar") : tr("Hide Bookmarks bar")); +} + +void BrowserMainWindow::slotViewStatusbar() +{ + if (statusBar()->isVisible()) { + updateStatusbarActionText(false); + statusBar()->close(); + } else { + updateStatusbarActionText(true); + statusBar()->show(); + } + m_autoSaver->changeOccurred(); +} + +QUrl BrowserMainWindow::guessUrlFromString(const QString &string) +{ + QString urlStr = string.trimmed(); + QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); + + // Check if it looks like a qualified URL. Try parsing it and see. + bool hasSchema = test.exactMatch(urlStr); + if (hasSchema) { + QUrl url(urlStr, QUrl::TolerantMode); + if (url.isValid()) + return url; + } + + // Might be a file. + if (QFile::exists(urlStr)) { + QFileInfo info(urlStr); + return QUrl::fromLocalFile(info.absoluteFilePath()); + } + + // Might be a shorturl - try to detect the schema. + if (!hasSchema) { + int dotIndex = urlStr.indexOf(QLatin1Char('.')); + if (dotIndex != -1) { + QString prefix = urlStr.left(dotIndex).toLower(); + QString schema = (prefix == QLatin1String("ftp")) ? prefix : QLatin1String("http"); + QUrl url(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode); + if (url.isValid()) + return url; + } + } + + // Fall back to QUrl's own tolerant parser. + QUrl url = QUrl(string, QUrl::TolerantMode); + + // finally for cases where the user just types in a hostname add http + if (url.scheme().isEmpty()) + url = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode); + return url; +} + +void BrowserMainWindow::loadUrl(const QUrl &url) +{ + loadPage(url.toString()); +} + +void BrowserMainWindow::slotDownloadManager() +{ + BrowserApplication::downloadManager()->show(); +} + +void BrowserMainWindow::slotSelectLineEdit() +{ + m_tabWidget->currentLineEdit()->selectAll(); + m_tabWidget->currentLineEdit()->setFocus(); +} + +void BrowserMainWindow::slotFileSaveAs() +{ + BrowserApplication::downloadManager()->download(currentTab()->url(), true); +} + +void BrowserMainWindow::slotPreferences() +{ + SettingsDialog *s = new SettingsDialog(this); + s->show(); +} + +void BrowserMainWindow::slotUpdateStatusbar(const QString &string) +{ + statusBar()->showMessage(string, 2000); +} + +void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) +{ + if (title.isEmpty()) { + setWindowTitle(tr("Qt Demo Browser")); + } else { +#if defined(Q_WS_MAC) + setWindowTitle(title); +#else + setWindowTitle(tr("%1 - Qt Demo Browser", "Page title and Browser name").arg(title)); +#endif + } +} + +void BrowserMainWindow::slotAboutApplication() +{ + QMessageBox::about(this, tr("About"), tr( + "Version %1" + "

This demo demonstrates Qt's " + "webkit facilities in action, providing an example " + "browser for you to experiment with.

" + "

QtWebKit is based on the Open Source WebKit Project developed at http://webkit.org/." + ).arg(QCoreApplication::applicationVersion())); +} + +void BrowserMainWindow::slotFileNew() +{ + BrowserApplication::instance()->newMainWindow(); + BrowserMainWindow *mw = BrowserApplication::instance()->mainWindow(); + mw->slotHome(); +} + +void BrowserMainWindow::slotFileOpen() +{ + QString file = QFileDialog::getOpenFileName(this, tr("Open Web Resource"), QString(), + tr("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)")); + + if (file.isEmpty()) + return; + + loadPage(file); +} + +void BrowserMainWindow::slotFilePrintPreview() +{ + if (!currentTab()) + return; + QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this); + connect(dialog, SIGNAL(paintRequested(QPrinter *)), + currentTab(), SLOT(print(QPrinter *))); + dialog->exec(); +} + +void BrowserMainWindow::slotFilePrint() +{ + if (!currentTab()) + return; + printRequested(currentTab()->page()->mainFrame()); +} + +void BrowserMainWindow::printRequested(QWebFrame *frame) +{ + QPrinter printer; + QPrintDialog *dialog = new QPrintDialog(&printer, this); + dialog->setWindowTitle(tr("Print Document")); + if (dialog->exec() != QDialog::Accepted) + return; + frame->print(&printer); +} + +void BrowserMainWindow::slotPrivateBrowsing() +{ + QWebSettings *settings = QWebSettings::globalSettings(); + bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); + if (!pb) { + QString title = tr("Are you sure you want to turn on private browsing?"); + QString text = tr("%1

When private browsing in turned on," + " webpages are not added to the history," + " items are automatically removed from the Downloads window," \ + " new cookies are not stored, current cookies can't be accessed," \ + " site icons wont be stored, session wont be saved, " \ + " and searches are not addded to the pop-up menu in the Google search box." \ + " Until you close the window, you can still click the Back and Forward buttons" \ + " to return to the webpages you have opened.").arg(title); + + QMessageBox::StandardButton button = QMessageBox::question(this, QString(), text, + QMessageBox::Ok | QMessageBox::Cancel, + QMessageBox::Ok); + if (button == QMessageBox::Ok) { + settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); + } + } else { + settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); + + QList windows = BrowserApplication::instance()->mainWindows(); + for (int i = 0; i < windows.count(); ++i) { + BrowserMainWindow *window = windows.at(i); + window->m_lastSearch = QString::null; + window->tabWidget()->clear(); + } + } +} + +void BrowserMainWindow::closeEvent(QCloseEvent *event) +{ + if (m_tabWidget->count() > 1) { + int ret = QMessageBox::warning(this, QString(), + tr("Are you sure you want to close the window?" + " There are %1 tab open").arg(m_tabWidget->count()), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); + if (ret == QMessageBox::No) { + event->ignore(); + return; + } + } + event->accept(); + deleteLater(); +} + +void BrowserMainWindow::slotEditFind() +{ + if (!currentTab()) + return; + bool ok; + QString search = QInputDialog::getText(this, tr("Find"), + tr("Text:"), QLineEdit::Normal, + m_lastSearch, &ok); + if (ok && !search.isEmpty()) { + m_lastSearch = search; + if (!currentTab()->findText(m_lastSearch)) + slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch)); + } +} + +void BrowserMainWindow::slotEditFindNext() +{ + if (!currentTab() && !m_lastSearch.isEmpty()) + return; + currentTab()->findText(m_lastSearch); +} + +void BrowserMainWindow::slotEditFindPrevious() +{ + if (!currentTab() && !m_lastSearch.isEmpty()) + return; + currentTab()->findText(m_lastSearch, QWebPage::FindBackward); +} + +void BrowserMainWindow::slotViewTextBigger() +{ + if (!currentTab()) + return; + currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() + 0.1); +} + +void BrowserMainWindow::slotViewTextNormal() +{ + if (!currentTab()) + return; + currentTab()->setTextSizeMultiplier(1.0); +} + +void BrowserMainWindow::slotViewTextSmaller() +{ + if (!currentTab()) + return; + currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() - 0.1); +} + +void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) +{ + if (makeFullScreen) { + showFullScreen(); + } else { + if (isMinimized()) + showMinimized(); + else if (isMaximized()) + showMaximized(); + else showNormal(); + } +} + +void BrowserMainWindow::slotViewPageSource() +{ + if (!currentTab()) + return; + + QString markup = currentTab()->page()->mainFrame()->toHtml(); + QPlainTextEdit *view = new QPlainTextEdit(markup); + view->setWindowTitle(tr("Page Source of %1").arg(currentTab()->title())); + view->setMinimumWidth(640); + view->setAttribute(Qt::WA_DeleteOnClose); + view->show(); +} + +void BrowserMainWindow::slotHome() +{ + QSettings settings; + settings.beginGroup(QLatin1String("MainWindow")); + QString home = settings.value(QLatin1String("home"), QLatin1String("http://www.trolltech.com/")).toString(); + loadPage(home); +} + +void BrowserMainWindow::slotWebSearch() +{ + m_toolbarSearch->lineEdit()->selectAll(); + m_toolbarSearch->lineEdit()->setFocus(); +} + +void BrowserMainWindow::slotToggleInspector(bool enable) +{ + QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); + if (enable) { + int result = QMessageBox::question(this, tr("Web Inspector"), + tr("The web inspector will only work correctly for pages that were loaded after enabling.\n" + "Do you want to reload all pages?"), + QMessageBox::Yes | QMessageBox::No); + if (result == QMessageBox::Yes) { + m_tabWidget->reloadAllTabs(); + } + } +} + +void BrowserMainWindow::slotSwapFocus() +{ + if (currentTab()->hasFocus()) + m_tabWidget->currentLineEdit()->setFocus(); + else + currentTab()->setFocus(); +} + +void BrowserMainWindow::loadPage(const QString &page) +{ + if (!currentTab() || page.isEmpty()) + return; + + QUrl url = guessUrlFromString(page); + m_tabWidget->currentLineEdit()->setText(url.toString()); + m_tabWidget->loadUrlInCurrentTab(url); +} + +TabWidget *BrowserMainWindow::tabWidget() const +{ + return m_tabWidget; +} + +WebView *BrowserMainWindow::currentTab() const +{ + return m_tabWidget->currentWebView(); +} + +void BrowserMainWindow::slotLoadProgress(int progress) +{ + if (progress < 100 && progress > 0) { + m_chaseWidget->setAnimated(true); + disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); + if (m_stopIcon.isNull()) + m_stopIcon = style()->standardIcon(QStyle::SP_BrowserStop); + m_stopReload->setIcon(m_stopIcon); + connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); + m_stopReload->setToolTip(tr("Stop loading the current page")); + } else { + m_chaseWidget->setAnimated(false); + disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); + m_stopReload->setIcon(m_reloadIcon); + connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); + m_stopReload->setToolTip(tr("Reload the current page")); + } +} + +void BrowserMainWindow::slotAboutToShowBackMenu() +{ + m_historyBackMenu->clear(); + if (!currentTab()) + return; + QWebHistory *history = currentTab()->history(); + int historyCount = history->count(); + for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { + QWebHistoryItem item = history->backItems(history->count()).at(i); + QAction *action = new QAction(this); + action->setData(-1*(historyCount-i-1)); + QIcon icon = BrowserApplication::instance()->icon(item.url()); + action->setIcon(icon); + action->setText(item.title()); + m_historyBackMenu->addAction(action); + } +} + +void BrowserMainWindow::slotAboutToShowForwardMenu() +{ + m_historyForwardMenu->clear(); + if (!currentTab()) + return; + QWebHistory *history = currentTab()->history(); + int historyCount = history->count(); + for (int i = 0; i < history->forwardItems(history->count()).count(); ++i) { + QWebHistoryItem item = history->forwardItems(historyCount).at(i); + QAction *action = new QAction(this); + action->setData(historyCount-i); + QIcon icon = BrowserApplication::instance()->icon(item.url()); + action->setIcon(icon); + action->setText(item.title()); + m_historyForwardMenu->addAction(action); + } +} + +void BrowserMainWindow::slotAboutToShowWindowMenu() +{ + m_windowMenu->clear(); + m_windowMenu->addAction(m_tabWidget->nextTabAction()); + m_windowMenu->addAction(m_tabWidget->previousTabAction()); + m_windowMenu->addSeparator(); + m_windowMenu->addAction(tr("Downloads"), this, SLOT(slotDownloadManager()), QKeySequence(tr("Alt+Ctrl+L", "Download Manager"))); + + m_windowMenu->addSeparator(); + QList windows = BrowserApplication::instance()->mainWindows(); + for (int i = 0; i < windows.count(); ++i) { + BrowserMainWindow *window = windows.at(i); + QAction *action = m_windowMenu->addAction(window->windowTitle(), this, SLOT(slotShowWindow())); + action->setData(i); + action->setCheckable(true); + if (window == this) + action->setChecked(true); + } +} + +void BrowserMainWindow::slotShowWindow() +{ + if (QAction *action = qobject_cast(sender())) { + QVariant v = action->data(); + if (v.canConvert()) { + int offset = qvariant_cast(v); + QList windows = BrowserApplication::instance()->mainWindows(); + windows.at(offset)->activateWindow(); + windows.at(offset)->currentTab()->setFocus(); + } + } +} + +void BrowserMainWindow::slotOpenActionUrl(QAction *action) +{ + int offset = action->data().toInt(); + QWebHistory *history = currentTab()->history(); + if (offset < 0) + history->goToItem(history->backItems(-1*offset).first()); // back + else if (offset > 0) + history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward + } + +void BrowserMainWindow::geometryChangeRequested(const QRect &geometry) +{ + setGeometry(geometry); +} diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h new file mode 100644 index 00000000..17f87056 --- /dev/null +++ b/src/browsermainwindow.h @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef BROWSERMAINWINDOW_H +#define BROWSERMAINWINDOW_H + +#include +#include +#include + +class AutoSaver; +class BookmarksToolBar; +class ChaseWidget; +class QWebFrame; +class TabWidget; +class ToolbarSearch; +class WebView; + +/*! + The MainWindow of the Browser Application. + + Handles the tab widget and all the actions + */ +class BrowserMainWindow : public QMainWindow { + Q_OBJECT + +public: + BrowserMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + ~BrowserMainWindow(); + QSize sizeHint() const; + +public: + static QUrl guessUrlFromString(const QString &url); + TabWidget *tabWidget() const; + WebView *currentTab() const; + QByteArray saveState(bool withTabs = true) const; + bool restoreState(const QByteArray &state); + +public slots: + void loadPage(const QString &url); + void slotHome(); + +protected: + void closeEvent(QCloseEvent *event); + +private slots: + void save(); + + void slotLoadProgress(int); + void slotUpdateStatusbar(const QString &string); + void slotUpdateWindowTitle(const QString &title = QString()); + + void loadUrl(const QUrl &url); + void slotPreferences(); + + void slotFileNew(); + void slotFileOpen(); + void slotFilePrintPreview(); + void slotFilePrint(); + void slotPrivateBrowsing(); + void slotFileSaveAs(); + void slotEditFind(); + void slotEditFindNext(); + void slotEditFindPrevious(); + void slotShowBookmarksDialog(); + void slotAddBookmark(); + void slotViewTextBigger(); + void slotViewTextNormal(); + void slotViewTextSmaller(); + void slotViewToolbar(); + void slotViewBookmarksBar(); + void slotViewStatusbar(); + void slotViewPageSource(); + void slotViewFullScreen(bool enable); + + void slotWebSearch(); + void slotToggleInspector(bool enable); + void slotAboutApplication(); + void slotDownloadManager(); + void slotSelectLineEdit(); + + void slotAboutToShowBackMenu(); + void slotAboutToShowForwardMenu(); + void slotAboutToShowWindowMenu(); + void slotOpenActionUrl(QAction *action); + void slotShowWindow(); + void slotSwapFocus(); + + void printRequested(QWebFrame *frame); + void geometryChangeRequested(const QRect &geometry); + void updateToolbarActionText(bool visible); + void updateBookmarksToolbarActionText(bool visible); + +private: + void loadDefaultState(); + void setupMenu(); + void setupToolBar(); + void updateStatusbarActionText(bool visible); + +private: + QToolBar *m_navigationBar; + ToolbarSearch *m_toolbarSearch; + BookmarksToolBar *m_bookmarksToolbar; + ChaseWidget *m_chaseWidget; + TabWidget *m_tabWidget; + AutoSaver *m_autoSaver; + + QAction *m_historyBack; + QMenu *m_historyBackMenu; + QAction *m_historyForward; + QMenu *m_historyForwardMenu; + QMenu *m_windowMenu; + + QAction *m_stop; + QAction *m_reload; + QAction *m_stopReload; + QAction *m_viewToolbar; + QAction *m_viewBookmarkBar; + QAction *m_viewStatusbar; + QAction *m_restoreLastSession; + QAction *m_addBookmark; + + QIcon m_reloadIcon; + QIcon m_stopIcon; + + QString m_lastSearch; +}; + +#endif // BROWSERMAINWINDOW_H + diff --git a/src/chasewidget.cpp b/src/chasewidget.cpp new file mode 100644 index 00000000..ea2b0f8e --- /dev/null +++ b/src/chasewidget.cpp @@ -0,0 +1,138 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "chasewidget.h" + +#include + +#include +#include +#include +#include +#include + +ChaseWidget::ChaseWidget(QWidget *parent, QPixmap pixmap, bool pixmapEnabled) + : QWidget(parent) + , m_segment(0) + , m_delay(100) + , m_step(40) + , m_timerId(-1) + , m_animated(false) + , m_pixmap(pixmap) + , m_pixmapEnabled(pixmapEnabled) +{ +} + +void ChaseWidget::setAnimated(bool value) +{ + if (m_animated == value) + return; + m_animated = value; + if (m_timerId != -1) { + killTimer(m_timerId); + m_timerId = -1; + } + if (m_animated) { + m_segment = 0; + m_timerId = startTimer(m_delay); + } + update(); +} + +void ChaseWidget::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter p(this); + if (m_pixmapEnabled && !m_pixmap.isNull()) { + p.drawPixmap(0, 0, m_pixmap); + return; + } + + const int extent = qMin(width() - 8, height() - 8); + const int displ = extent / 4; + const int ext = extent / 4 - 1; + + p.setRenderHint(QPainter::Antialiasing, true); + + if(m_animated) + p.setPen(Qt::gray); + else + p.setPen(QPen(palette().dark().color())); + + p.translate(width() / 2, height() / 2); // center + + for (int segment = 0; segment < segmentCount(); ++segment) { + p.rotate(QApplication::isRightToLeft() ? m_step : -m_step); + if(m_animated) + p.setBrush(colorForSegment(segment)); + else + p.setBrush(palette().background()); + p.drawEllipse(QRect(displ, -ext / 2, ext, ext)); + } +} + +QSize ChaseWidget::sizeHint() const +{ + return QSize(32, 32); +} + +void ChaseWidget::timerEvent(QTimerEvent *event) +{ + if (event->timerId() == m_timerId) { + ++m_segment; + update(); + } + QWidget::timerEvent(event); +} + +QColor ChaseWidget::colorForSegment(int seg) const +{ + int index = ((seg + m_segment) % segmentCount()); + int comp = qMax(0, 255 - (index * (255 / segmentCount()))); + return QColor(comp, comp, comp, 255); +} + +int ChaseWidget::segmentCount() const +{ + return 360 / m_step; +} + +void ChaseWidget::setPixmapEnabled(bool enable) +{ + m_pixmapEnabled = enable; +} + diff --git a/src/chasewidget.h b/src/chasewidget.h new file mode 100644 index 00000000..ce5b2dae --- /dev/null +++ b/src/chasewidget.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef CHASEWIDGET_H +#define CHASEWIDGET_H + +#include + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QHideEvent; +class QShowEvent; +class QPaintEvent; +class QTimerEvent; +QT_END_NAMESPACE + +class ChaseWidget : public QWidget +{ + Q_OBJECT +public: + ChaseWidget(QWidget *parent = 0, QPixmap pixmap = QPixmap(), bool pixmapEnabled = false); + + void setAnimated(bool value); + void setPixmapEnabled(bool enable); + QSize sizeHint() const; + +protected: + void paintEvent(QPaintEvent *event); + void timerEvent(QTimerEvent *event); + +private: + int segmentCount() const; + QColor colorForSegment(int segment) const; + + int m_segment; + int m_delay; + int m_step; + int m_timerId; + bool m_animated; + QPixmap m_pixmap; + bool m_pixmapEnabled; +}; + +#endif diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp new file mode 100644 index 00000000..bed7258a --- /dev/null +++ b/src/cookiejar.cpp @@ -0,0 +1,728 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "cookiejar.h" + +#include "autosaver.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +static const unsigned int JAR_VERSION = 23; + +QT_BEGIN_NAMESPACE +QDataStream &operator<<(QDataStream &stream, const QList &list) +{ + stream << JAR_VERSION; + stream << quint32(list.size()); + for (int i = 0; i < list.size(); ++i) + stream << list.at(i).toRawForm(); + return stream; +} + +QDataStream &operator>>(QDataStream &stream, QList &list) +{ + list.clear(); + + quint32 version; + stream >> version; + + if (version != JAR_VERSION) + return stream; + + quint32 count; + stream >> count; + for(quint32 i = 0; i < count; ++i) + { + QByteArray value; + stream >> value; + QList newCookies = QNetworkCookie::parseCookies(value); + if (newCookies.count() == 0 && value.length() != 0) { + qWarning() << "CookieJar: Unable to parse saved cookie:" << value; + } + for (int j = 0; j < newCookies.count(); ++j) + list.append(newCookies.at(j)); + if (stream.atEnd()) + break; + } + return stream; +} +QT_END_NAMESPACE + +CookieJar::CookieJar(QObject *parent) + : QNetworkCookieJar(parent) + , m_loaded(false) + , m_saveTimer(new AutoSaver(this)) + , m_acceptCookies(AcceptOnlyFromSitesNavigatedTo) +{ +} + +CookieJar::~CookieJar() +{ + if (m_keepCookies == KeepUntilExit) + clear(); + m_saveTimer->saveIfNeccessary(); +} + +void CookieJar::clear() +{ + setAllCookies(QList()); + m_saveTimer->changeOccurred(); + emit cookiesChanged(); +} + +void CookieJar::load() +{ + if (m_loaded) + return; + // load cookies and exceptions + qRegisterMetaTypeStreamOperators >("QList"); + QSettings cookieSettings(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/cookies.ini"), QSettings::IniFormat); + setAllCookies(qvariant_cast >(cookieSettings.value(QLatin1String("cookies")))); + cookieSettings.beginGroup(QLatin1String("Exceptions")); + m_exceptions_block = cookieSettings.value(QLatin1String("block")).toStringList(); + m_exceptions_allow = cookieSettings.value(QLatin1String("allow")).toStringList(); + m_exceptions_allowForSession = cookieSettings.value(QLatin1String("allowForSession")).toStringList(); + qSort(m_exceptions_block.begin(), m_exceptions_block.end()); + qSort(m_exceptions_allow.begin(), m_exceptions_allow.end()); + qSort(m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end()); + + loadSettings(); +} + +void CookieJar::loadSettings() +{ + QSettings settings; + settings.beginGroup(QLatin1String("cookies")); + QByteArray value = settings.value(QLatin1String("acceptCookies"), + QLatin1String("AcceptOnlyFromSitesNavigatedTo")).toByteArray(); + QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AcceptPolicy")); + m_acceptCookies = acceptPolicyEnum.keyToValue(value) == -1 ? + AcceptOnlyFromSitesNavigatedTo : + static_cast(acceptPolicyEnum.keyToValue(value)); + + value = settings.value(QLatin1String("keepCookiesUntil"), QLatin1String("KeepUntilExpire")).toByteArray(); + QMetaEnum keepPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("KeepPolicy")); + m_keepCookies = keepPolicyEnum.keyToValue(value) == -1 ? + KeepUntilExpire : + static_cast(keepPolicyEnum.keyToValue(value)); + + if (m_keepCookies == KeepUntilExit) + setAllCookies(QList()); + + m_loaded = true; + emit cookiesChanged(); +} + +void CookieJar::save() +{ + if (!m_loaded) + return; + purgeOldCookies(); + QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + if (directory.isEmpty()) + directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); + if (!QFile::exists(directory)) { + QDir dir; + dir.mkpath(directory); + } + QSettings cookieSettings(directory + QLatin1String("/cookies.ini"), QSettings::IniFormat); + QList cookies = allCookies(); + for (int i = cookies.count() - 1; i >= 0; --i) { + if (cookies.at(i).isSessionCookie()) + cookies.removeAt(i); + } + cookieSettings.setValue(QLatin1String("cookies"), qVariantFromValue >(cookies)); + cookieSettings.beginGroup(QLatin1String("Exceptions")); + cookieSettings.setValue(QLatin1String("block"), m_exceptions_block); + cookieSettings.setValue(QLatin1String("allow"), m_exceptions_allow); + cookieSettings.setValue(QLatin1String("allowForSession"), m_exceptions_allowForSession); + + // save cookie settings + QSettings settings; + settings.beginGroup(QLatin1String("cookies")); + QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AcceptPolicy")); + settings.setValue(QLatin1String("acceptCookies"), QLatin1String(acceptPolicyEnum.valueToKey(m_acceptCookies))); + + QMetaEnum keepPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("KeepPolicy")); + settings.setValue(QLatin1String("keepCookiesUntil"), QLatin1String(keepPolicyEnum.valueToKey(m_keepCookies))); +} + +void CookieJar::purgeOldCookies() +{ + QList cookies = allCookies(); + if (cookies.isEmpty()) + return; + int oldCount = cookies.count(); + QDateTime now = QDateTime::currentDateTime(); + for (int i = cookies.count() - 1; i >= 0; --i) { + if (!cookies.at(i).isSessionCookie() && cookies.at(i).expirationDate() < now) + cookies.removeAt(i); + } + if (oldCount == cookies.count()) + return; + setAllCookies(cookies); + emit cookiesChanged(); +} + +QList CookieJar::cookiesForUrl(const QUrl &url) const +{ + CookieJar *that = const_cast(this); + if (!m_loaded) + that->load(); + + QWebSettings *globalSettings = QWebSettings::globalSettings(); + if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { + QList noCookies; + return noCookies; + } + + return QNetworkCookieJar::cookiesForUrl(url); +} + +bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url) +{ + if (!m_loaded) + load(); + + QWebSettings *globalSettings = QWebSettings::globalSettings(); + if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + return false; + + QString host = url.host(); + bool eBlock = qBinaryFind(m_exceptions_block.begin(), m_exceptions_block.end(), host) != m_exceptions_block.end(); + bool eAllow = qBinaryFind(m_exceptions_allow.begin(), m_exceptions_allow.end(), host) != m_exceptions_allow.end(); + bool eAllowSession = qBinaryFind(m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end(), host) != m_exceptions_allowForSession.end(); + + bool addedCookies = false; + // pass exceptions + bool acceptInitially = (m_acceptCookies != AcceptNever); + if ((acceptInitially && !eBlock) + || (!acceptInitially && (eAllow || eAllowSession))) { + // pass url domain == cookie domain + QDateTime soon = QDateTime::currentDateTime(); + soon = soon.addDays(90); + foreach(QNetworkCookie cookie, cookieList) { + QList lst; + if (m_keepCookies == KeepUntilTimeLimit + && !cookie.isSessionCookie() + && cookie.expirationDate() > soon) { + cookie.setExpirationDate(soon); + } + lst += cookie; + if (QNetworkCookieJar::setCookiesFromUrl(lst, url)) { + addedCookies = true; + } else { + // finally force it in if wanted + if (m_acceptCookies == AcceptAlways) { + QList cookies = allCookies(); + cookies += cookie; + setAllCookies(cookies); + addedCookies = true; + } +#if 0 + else + qWarning() << "setCookiesFromUrl failed" << url << cookieList.value(0).toRawForm(); +#endif + } + } + } + + if (addedCookies) { + m_saveTimer->changeOccurred(); + emit cookiesChanged(); + } + return addedCookies; +} + +CookieJar::AcceptPolicy CookieJar::acceptPolicy() const +{ + if (!m_loaded) + (const_cast(this))->load(); + return m_acceptCookies; +} + +void CookieJar::setAcceptPolicy(AcceptPolicy policy) +{ + if (!m_loaded) + load(); + if (policy == m_acceptCookies) + return; + m_acceptCookies = policy; + m_saveTimer->changeOccurred(); +} + +CookieJar::KeepPolicy CookieJar::keepPolicy() const +{ + if (!m_loaded) + (const_cast(this))->load(); + return m_keepCookies; +} + +void CookieJar::setKeepPolicy(KeepPolicy policy) +{ + if (!m_loaded) + load(); + if (policy == m_keepCookies) + return; + m_keepCookies = policy; + m_saveTimer->changeOccurred(); +} + +QStringList CookieJar::blockedCookies() const +{ + if (!m_loaded) + (const_cast(this))->load(); + return m_exceptions_block; +} + +QStringList CookieJar::allowedCookies() const +{ + if (!m_loaded) + (const_cast(this))->load(); + return m_exceptions_allow; +} + +QStringList CookieJar::allowForSessionCookies() const +{ + if (!m_loaded) + (const_cast(this))->load(); + return m_exceptions_allowForSession; +} + +void CookieJar::setBlockedCookies(const QStringList &list) +{ + if (!m_loaded) + load(); + m_exceptions_block = list; + qSort(m_exceptions_block.begin(), m_exceptions_block.end()); + m_saveTimer->changeOccurred(); +} + +void CookieJar::setAllowedCookies(const QStringList &list) +{ + if (!m_loaded) + load(); + m_exceptions_allow = list; + qSort(m_exceptions_allow.begin(), m_exceptions_allow.end()); + m_saveTimer->changeOccurred(); +} + +void CookieJar::setAllowForSessionCookies(const QStringList &list) +{ + if (!m_loaded) + load(); + m_exceptions_allowForSession = list; + qSort(m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end()); + m_saveTimer->changeOccurred(); +} + +CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) + : QAbstractTableModel(parent) + , m_cookieJar(cookieJar) +{ + connect(m_cookieJar, SIGNAL(cookiesChanged()), this, SLOT(cookiesChanged())); + m_cookieJar->load(); +} + +QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::SizeHintRole) { + QFont font; + font.setPointSize(10); + QFontMetrics fm(font); + int height = fm.height() + fm.height()/3; + int width = fm.width(headerData(section, orientation, Qt::DisplayRole).toString()); + return QSize(width, height); + } + + if (orientation == Qt::Horizontal) { + if (role != Qt::DisplayRole) + return QVariant(); + + switch (section) { + case 0: + return tr("Website"); + case 1: + return tr("Name"); + case 2: + return tr("Path"); + case 3: + return tr("Secure"); + case 4: + return tr("Expires"); + case 5: + return tr("Contents"); + default: + return QVariant(); + } + } + return QAbstractTableModel::headerData(section, orientation, role); +} + +QVariant CookieModel::data(const QModelIndex &index, int role) const +{ + QList lst; + if (m_cookieJar) + lst = m_cookieJar->allCookies(); + if (index.row() < 0 || index.row() >= lst.size()) + return QVariant(); + + switch (role) { + case Qt::DisplayRole: + case Qt::EditRole: { + QNetworkCookie cookie = lst.at(index.row()); + switch (index.column()) { + case 0: + return cookie.domain(); + case 1: + return cookie.name(); + case 2: + return cookie.path(); + case 3: + return cookie.isSecure(); + case 4: + return cookie.expirationDate(); + case 5: + return cookie.value(); + } + } + case Qt::FontRole:{ + QFont font; + font.setPointSize(10); + return font; + } + } + + return QVariant(); +} + +int CookieModel::columnCount(const QModelIndex &parent) const +{ + return (parent.isValid()) ? 0 : 6; +} + +int CookieModel::rowCount(const QModelIndex &parent) const +{ + return (parent.isValid() || !m_cookieJar) ? 0 : m_cookieJar->allCookies().count(); +} + +bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (parent.isValid() || !m_cookieJar) + return false; + int lastRow = row + count - 1; + beginRemoveRows(parent, row, lastRow); + QList lst = m_cookieJar->allCookies(); + for (int i = lastRow; i >= row; --i) { + lst.removeAt(i); + } + m_cookieJar->setAllCookies(lst); + endRemoveRows(); + return true; +} + +void CookieModel::cookiesChanged() +{ + reset(); +} + +CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) : QDialog(parent) +{ + setupUi(this); + setWindowFlags(Qt::Sheet); + CookieModel *model = new CookieModel(cookieJar, this); + m_proxyModel = new QSortFilterProxyModel(this); + connect(search, SIGNAL(textChanged(QString)), + m_proxyModel, SLOT(setFilterFixedString(QString))); + connect(removeButton, SIGNAL(clicked()), cookiesTable, SLOT(removeOne())); + connect(removeAllButton, SIGNAL(clicked()), cookiesTable, SLOT(removeAll())); + m_proxyModel->setSourceModel(model); + cookiesTable->verticalHeader()->hide(); + cookiesTable->setSelectionBehavior(QAbstractItemView::SelectRows); + cookiesTable->setModel(m_proxyModel); + cookiesTable->setAlternatingRowColors(true); + cookiesTable->setTextElideMode(Qt::ElideMiddle); + cookiesTable->setShowGrid(false); + cookiesTable->setSortingEnabled(true); + QFont f = font(); + f.setPointSize(10); + QFontMetrics fm(f); + int height = fm.height() + fm.height()/3; + cookiesTable->verticalHeader()->setDefaultSectionSize(height); + cookiesTable->verticalHeader()->setMinimumSectionSize(-1); + for (int i = 0; i < model->columnCount(); ++i){ + int header = cookiesTable->horizontalHeader()->sectionSizeHint(i); + switch (i) { + case 0: + header = fm.width(QLatin1String("averagehost.domain.com")); + break; + case 1: + header = fm.width(QLatin1String("_session_id")); + break; + case 4: + header = fm.width(QDateTime::currentDateTime().toString(Qt::LocalDate)); + break; + } + int buffer = fm.width(QLatin1String("xx")); + header += buffer; + cookiesTable->horizontalHeader()->resizeSection(i, header); + } + cookiesTable->horizontalHeader()->setStretchLastSection(true); +} + + + +CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent) + : QAbstractTableModel(parent) + , m_cookieJar(cookiejar) +{ + m_allowedCookies = m_cookieJar->allowedCookies(); + m_blockedCookies = m_cookieJar->blockedCookies(); + m_sessionCookies = m_cookieJar->allowForSessionCookies(); +} + +QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::SizeHintRole) { + QFont font; + font.setPointSize(10); + QFontMetrics fm(font); + int height = fm.height() + fm.height()/3; + int width = fm.width(headerData(section, orientation, Qt::DisplayRole).toString()); + return QSize(width, height); + } + + if (orientation == Qt::Horizontal + && role == Qt::DisplayRole) { + switch (section) { + case 0: + return tr("Website"); + case 1: + return tr("Status"); + } + } + return QAbstractTableModel::headerData(section, orientation, role); +} + +QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const +{ + if (index.row() < 0 || index.row() >= rowCount()) + return QVariant(); + + switch (role) { + case Qt::DisplayRole: + case Qt::EditRole: { + int row = index.row(); + if (row < m_allowedCookies.count()) { + switch (index.column()) { + case 0: + return m_allowedCookies.at(row); + case 1: + return tr("Allow"); + } + } + row = row - m_allowedCookies.count(); + if (row < m_blockedCookies.count()) { + switch (index.column()) { + case 0: + return m_blockedCookies.at(row); + case 1: + return tr("Block"); + } + } + row = row - m_blockedCookies.count(); + if (row < m_sessionCookies.count()) { + switch (index.column()) { + case 0: + return m_sessionCookies.at(row); + case 1: + return tr("Allow For Session"); + } + } + } + case Qt::FontRole:{ + QFont font; + font.setPointSize(10); + return font; + } + } + return QVariant(); +} + +int CookieExceptionsModel::columnCount(const QModelIndex &parent) const +{ + return (parent.isValid()) ? 0 : 2; +} + +int CookieExceptionsModel::rowCount(const QModelIndex &parent) const +{ + return (parent.isValid() || !m_cookieJar) ? 0 : m_allowedCookies.count() + m_blockedCookies.count() + m_sessionCookies.count(); +} + +bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (parent.isValid() || !m_cookieJar) + return false; + + int lastRow = row + count - 1; + beginRemoveRows(parent, row, lastRow); + for (int i = lastRow; i >= row; --i) { + if (i < m_allowedCookies.count()) { + m_allowedCookies.removeAt(row); + continue; + } + i = i - m_allowedCookies.count(); + if (i < m_blockedCookies.count()) { + m_blockedCookies.removeAt(row); + continue; + } + i = i - m_blockedCookies.count(); + if (i < m_sessionCookies.count()) { + m_sessionCookies.removeAt(row); + continue; + } + } + m_cookieJar->setAllowedCookies(m_allowedCookies); + m_cookieJar->setBlockedCookies(m_blockedCookies); + m_cookieJar->setAllowForSessionCookies(m_sessionCookies); + endRemoveRows(); + return true; +} + +CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent) + : QDialog(parent) + , m_cookieJar(cookieJar) +{ + setupUi(this); + setWindowFlags(Qt::Sheet); + connect(removeButton, SIGNAL(clicked()), exceptionTable, SLOT(removeOne())); + connect(removeAllButton, SIGNAL(clicked()), exceptionTable, SLOT(removeAll())); + exceptionTable->verticalHeader()->hide(); + exceptionTable->setSelectionBehavior(QAbstractItemView::SelectRows); + exceptionTable->setAlternatingRowColors(true); + exceptionTable->setTextElideMode(Qt::ElideMiddle); + exceptionTable->setShowGrid(false); + exceptionTable->setSortingEnabled(true); + m_exceptionsModel = new CookieExceptionsModel(cookieJar, this); + m_proxyModel = new QSortFilterProxyModel(this); + m_proxyModel->setSourceModel(m_exceptionsModel); + connect(search, SIGNAL(textChanged(QString)), + m_proxyModel, SLOT(setFilterFixedString(QString))); + exceptionTable->setModel(m_proxyModel); + + CookieModel *cookieModel = new CookieModel(cookieJar, this); + domainLineEdit->setCompleter(new QCompleter(cookieModel, domainLineEdit)); + + connect(domainLineEdit, SIGNAL(textChanged(const QString &)), + this, SLOT(textChanged(const QString &))); + connect(blockButton, SIGNAL(clicked()), this, SLOT(block())); + connect(allowButton, SIGNAL(clicked()), this, SLOT(allow())); + connect(allowForSessionButton, SIGNAL(clicked()), this, SLOT(allowForSession())); + + QFont f = font(); + f.setPointSize(10); + QFontMetrics fm(f); + int height = fm.height() + fm.height()/3; + exceptionTable->verticalHeader()->setDefaultSectionSize(height); + exceptionTable->verticalHeader()->setMinimumSectionSize(-1); + for (int i = 0; i < m_exceptionsModel->columnCount(); ++i){ + int header = exceptionTable->horizontalHeader()->sectionSizeHint(i); + switch (i) { + case 0: + header = fm.width(QLatin1String("averagebiglonghost.domain.com")); + break; + case 1: + header = fm.width(QLatin1String("Allow For Session")); + break; + } + int buffer = fm.width(QLatin1String("xx")); + header += buffer; + exceptionTable->horizontalHeader()->resizeSection(i, header); + } +} + +void CookiesExceptionsDialog::textChanged(const QString &text) +{ + bool enabled = !text.isEmpty(); + blockButton->setEnabled(enabled); + allowButton->setEnabled(enabled); + allowForSessionButton->setEnabled(enabled); +} + +void CookiesExceptionsDialog::block() +{ + if (domainLineEdit->text().isEmpty()) + return; + m_exceptionsModel->m_blockedCookies.append(domainLineEdit->text()); + m_cookieJar->setBlockedCookies(m_exceptionsModel->m_blockedCookies); + m_exceptionsModel->reset(); +} + +void CookiesExceptionsDialog::allow() +{ + if (domainLineEdit->text().isEmpty()) + return; + m_exceptionsModel->m_allowedCookies.append(domainLineEdit->text()); + m_cookieJar->setAllowedCookies(m_exceptionsModel->m_allowedCookies); + m_exceptionsModel->reset(); +} + +void CookiesExceptionsDialog::allowForSession() +{ + if (domainLineEdit->text().isEmpty()) + return; + m_exceptionsModel->m_sessionCookies.append(domainLineEdit->text()); + m_cookieJar->setAllowForSessionCookies(m_exceptionsModel->m_sessionCookies); + m_exceptionsModel->reset(); +} diff --git a/src/cookiejar.h b/src/cookiejar.h new file mode 100644 index 00000000..50d007f0 --- /dev/null +++ b/src/cookiejar.h @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef COOKIEJAR_H +#define COOKIEJAR_H + +#include + +#include +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QSortFilterProxyModel; +class QKeyEvent; +QT_END_NAMESPACE + +class AutoSaver; + +class CookieJar : public QNetworkCookieJar +{ + friend class CookieModel; + Q_OBJECT + Q_PROPERTY(AcceptPolicy acceptPolicy READ acceptPolicy WRITE setAcceptPolicy) + Q_PROPERTY(KeepPolicy keepPolicy READ keepPolicy WRITE setKeepPolicy) + Q_PROPERTY(QStringList blockedCookies READ blockedCookies WRITE setBlockedCookies) + Q_PROPERTY(QStringList allowedCookies READ allowedCookies WRITE setAllowedCookies) + Q_PROPERTY(QStringList allowForSessionCookies READ allowForSessionCookies WRITE setAllowForSessionCookies) + Q_ENUMS(KeepPolicy) + Q_ENUMS(AcceptPolicy) + +signals: + void cookiesChanged(); + +public: + enum AcceptPolicy { + AcceptAlways, + AcceptNever, + AcceptOnlyFromSitesNavigatedTo + }; + + enum KeepPolicy { + KeepUntilExpire, + KeepUntilExit, + KeepUntilTimeLimit + }; + + CookieJar(QObject *parent = 0); + ~CookieJar(); + + QList cookiesForUrl(const QUrl &url) const; + bool setCookiesFromUrl(const QList &cookieList, const QUrl &url); + + AcceptPolicy acceptPolicy() const; + void setAcceptPolicy(AcceptPolicy policy); + + KeepPolicy keepPolicy() const; + void setKeepPolicy(KeepPolicy policy); + + QStringList blockedCookies() const; + QStringList allowedCookies() const; + QStringList allowForSessionCookies() const; + + void setBlockedCookies(const QStringList &list); + void setAllowedCookies(const QStringList &list); + void setAllowForSessionCookies(const QStringList &list); + +public slots: + void clear(); + void loadSettings(); + +private slots: + void save(); + +private: + void purgeOldCookies(); + void load(); + bool m_loaded; + AutoSaver *m_saveTimer; + + AcceptPolicy m_acceptCookies; + KeepPolicy m_keepCookies; + + QStringList m_exceptions_block; + QStringList m_exceptions_allow; + QStringList m_exceptions_allowForSession; +}; + +class CookieModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + CookieModel(CookieJar *jar, QObject *parent = 0); + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + +private slots: + void cookiesChanged(); + +private: + CookieJar *m_cookieJar; +}; + +#include "ui_cookies.h" +#include "ui_cookiesexceptions.h" + +class CookiesDialog : public QDialog, public Ui_CookiesDialog +{ + Q_OBJECT + +public: + CookiesDialog(CookieJar *cookieJar, QWidget *parent = 0); + +private: + QSortFilterProxyModel *m_proxyModel; +}; + +class CookieExceptionsModel : public QAbstractTableModel +{ + Q_OBJECT + friend class CookiesExceptionsDialog; + +public: + CookieExceptionsModel(CookieJar *cookieJar, QObject *parent = 0); + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + +private: + CookieJar *m_cookieJar; + + // Domains we allow, Domains we block, Domains we allow for this session + QStringList m_allowedCookies; + QStringList m_blockedCookies; + QStringList m_sessionCookies; +}; + +class CookiesExceptionsDialog : public QDialog, public Ui_CookiesExceptionsDialog +{ + Q_OBJECT + +public: + CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent = 0); + +private slots: + void block(); + void allow(); + void allowForSession(); + void textChanged(const QString &text); + +private: + CookieExceptionsModel *m_exceptionsModel; + QSortFilterProxyModel *m_proxyModel; + CookieJar *m_cookieJar; +}; + +#endif // COOKIEJAR_H + diff --git a/src/cookies.ui b/src/cookies.ui new file mode 100644 index 00000000..c4bccc54 --- /dev/null +++ b/src/cookies.ui @@ -0,0 +1,106 @@ + + CookiesDialog + + + + 0 + 0 + 550 + 370 + + + + Cookies + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + + + &Remove + + + + + + + Remove &All Cookies + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + + SearchLineEdit + QLineEdit +

searchlineedit.h
+ + + EditTableView + QTableView +
edittableview.h
+
+ + + + + buttonBox + accepted() + CookiesDialog + accept() + + + 472 + 329 + + + 461 + 356 + + + + + diff --git a/src/cookiesexceptions.ui b/src/cookiesexceptions.ui new file mode 100644 index 00000000..3d9ef624 --- /dev/null +++ b/src/cookiesexceptions.ui @@ -0,0 +1,184 @@ + + CookiesExceptionsDialog + + + + 0 + 0 + 466 + 446 + + + + Cookie Exceptions + + + + + + New Exception + + + + + + + + Domain: + + + + + + + + + + + + + + Qt::Horizontal + + + + 81 + 25 + + + + + + + + false + + + Block + + + + + + + false + + + Allow For Session + + + + + + + false + + + Allow + + + + + + + + + + + + Exceptions + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + &Remove + + + + + + + Remove &All + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + SearchLineEdit + QLineEdit +
searchlineedit.h
+
+ + EditTableView + QTableView +
edittableview.h
+
+
+ + + + buttonBox + accepted() + CookiesExceptionsDialog + accept() + + + 381 + 428 + + + 336 + 443 + + + + +
diff --git a/src/data/addtab.png b/src/data/addtab.png new file mode 100644 index 00000000..20928fb4 Binary files /dev/null and b/src/data/addtab.png differ diff --git a/src/data/browser.svg b/src/data/browser.svg new file mode 100644 index 00000000..c42af2bc --- /dev/null +++ b/src/data/browser.svg @@ -0,0 +1,1598 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/data/closetab.png b/src/data/closetab.png new file mode 100644 index 00000000..ab9d669e Binary files /dev/null and b/src/data/closetab.png differ diff --git a/src/data/data.qrc b/src/data/data.qrc new file mode 100644 index 00000000..c7d0294c --- /dev/null +++ b/src/data/data.qrc @@ -0,0 +1,11 @@ + + + addtab.png + closetab.png + history.png + browser.svg + defaultbookmarks.xbel + loading.gif + defaulticon.png + + diff --git a/src/data/defaultbookmarks.xbel b/src/data/defaultbookmarks.xbel new file mode 100644 index 00000000..f1c9253d --- /dev/null +++ b/src/data/defaultbookmarks.xbel @@ -0,0 +1,40 @@ + + + + + Bookmarks Bar + + Trolltech.com + + + WebKit.org + + + Qt Documentation + + + Qt Quarterly + + + Trolltech Labs + + + Qt Centre + + + Qt-Apps.org + + + qtnode + + + xkcd + + + + Bookmarks Menu + + reddit.com: what's new online! + + + diff --git a/src/data/defaulticon.png b/src/data/defaulticon.png new file mode 100644 index 00000000..01a0920c Binary files /dev/null and b/src/data/defaulticon.png differ diff --git a/src/data/history.png b/src/data/history.png new file mode 100644 index 00000000..552a1cbd Binary files /dev/null and b/src/data/history.png differ diff --git a/src/data/loading.gif b/src/data/loading.gif new file mode 100644 index 00000000..c1545eb0 Binary files /dev/null and b/src/data/loading.gif differ diff --git a/src/downloaditem.ui b/src/downloaditem.ui new file mode 100644 index 00000000..4a0a0fd9 --- /dev/null +++ b/src/downloaditem.ui @@ -0,0 +1,134 @@ + + DownloadItem + + + + 0 + 0 + 423 + 110 + + + + Form + + + + 0 + + + + + + 0 + 0 + + + + Ico + + + + + + + + + + 0 + 0 + + + + Filename + + + + + + + 0 + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + Qt::Vertical + + + + 17 + 1 + + + + + + + + false + + + Try Again + + + + + + + Stop + + + + + + + Open + + + + + + + Qt::Vertical + + + + 17 + 5 + + + + + + + + + + + SqueezeLabel + QWidget +
squeezelabel.h
+
+
+ + +
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp new file mode 100644 index 00000000..d8f19c5e --- /dev/null +++ b/src/downloadmanager.cpp @@ -0,0 +1,575 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "downloadmanager.h" + +#include "autosaver.h" +#include "browserapplication.h" +#include "networkaccessmanager.h" + +#include + +#include +#include + +#include +#include +#include +#include + +#include + +#include + +/*! + DownloadItem is a widget that is displayed in the download manager list. + It moves the data from the QNetworkReply into the QFile as well + as update the information/progressbar and report errors. + */ +DownloadItem::DownloadItem(QNetworkReply *reply, bool requestFileName, QWidget *parent) + : QWidget(parent) + , m_reply(reply) + , m_requestFileName(requestFileName) + , m_bytesReceived(0) +{ + setupUi(this); + QPalette p = downloadInfoLabel->palette(); + p.setColor(QPalette::Text, Qt::darkGray); + downloadInfoLabel->setPalette(p); + progressBar->setMaximum(0); + tryAgainButton->hide(); + connect(stopButton, SIGNAL(clicked()), this, SLOT(stop())); + connect(openButton, SIGNAL(clicked()), this, SLOT(open())); + connect(tryAgainButton, SIGNAL(clicked()), this, SLOT(tryAgain())); + + init(); +} + +void DownloadItem::init() +{ + if (!m_reply) + return; + + // attach to the m_reply + m_url = m_reply->url(); + m_reply->setParent(this); + connect(m_reply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead())); + connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), + this, SLOT(error(QNetworkReply::NetworkError))); + connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), + this, SLOT(downloadProgress(qint64, qint64))); + connect(m_reply, SIGNAL(metaDataChanged()), + this, SLOT(metaDataChanged())); + connect(m_reply, SIGNAL(finished()), + this, SLOT(finished())); + + // reset info + downloadInfoLabel->clear(); + progressBar->setValue(0); + getFileName(); + + // start timer for the download estimation + m_downloadTime.start(); + + if (m_reply->error() != QNetworkReply::NoError) { + error(m_reply->error()); + finished(); + } +} + +void DownloadItem::getFileName() +{ + QSettings settings; + settings.beginGroup(QLatin1String("downloadmanager")); + QString defaultLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); + QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), defaultLocation).toString(); + if (!downloadDirectory.isEmpty()) + downloadDirectory += QLatin1Char('/'); + + QString defaultFileName = saveFileName(downloadDirectory); + QString fileName = defaultFileName; + if (m_requestFileName) { + fileName = QFileDialog::getSaveFileName(this, tr("Save File"), defaultFileName); + if (fileName.isEmpty()) { + m_reply->close(); + fileNameLabel->setText(tr("Download canceled: %1").arg(QFileInfo(defaultFileName).fileName())); + return; + } + } + m_output.setFileName(fileName); + fileNameLabel->setText(QFileInfo(m_output.fileName()).fileName()); + if (m_requestFileName) + downloadReadyRead(); +} + +QString DownloadItem::saveFileName(const QString &directory) const +{ + // Move this function into QNetworkReply to also get file name sent from the server + QString path = m_url.path(); + QFileInfo info(path); + QString baseName = info.completeBaseName(); + QString endName = info.suffix(); + + if (baseName.isEmpty()) { + baseName = QLatin1String("unnamed_download"); + qDebug() << "DownloadManager:: downloading unknown file:" << m_url; + } + QString name = directory + baseName + QLatin1Char('.') + endName; + if (QFile::exists(name)) { + // already exists, don't overwrite + int i = 1; + do { + name = directory + baseName + QLatin1Char('-') + QString::number(i++) + QLatin1Char('.') + endName; + } while (QFile::exists(name)); + } + return name; +} + + +void DownloadItem::stop() +{ + setUpdatesEnabled(false); + stopButton->setEnabled(false); + stopButton->hide(); + tryAgainButton->setEnabled(true); + tryAgainButton->show(); + setUpdatesEnabled(true); + m_reply->abort(); +} + +void DownloadItem::open() +{ + QFileInfo info(m_output); + QUrl url = QUrl::fromLocalFile(info.absolutePath()); + QDesktopServices::openUrl(url); +} + +void DownloadItem::tryAgain() +{ + if (!tryAgainButton->isEnabled()) + return; + + tryAgainButton->setEnabled(false); + tryAgainButton->setVisible(false); + stopButton->setEnabled(true); + stopButton->setVisible(true); + progressBar->setVisible(true); + + QNetworkReply *r = BrowserApplication::networkAccessManager()->get(QNetworkRequest(m_url)); + if (m_reply) + m_reply->deleteLater(); + if (m_output.exists()) + m_output.remove(); + m_reply = r; + init(); + emit statusChanged(); +} + +void DownloadItem::downloadReadyRead() +{ + if (m_requestFileName && m_output.fileName().isEmpty()) + return; + if (!m_output.isOpen()) { + // in case someone else has already put a file there + if (!m_requestFileName) + getFileName(); + if (!m_output.open(QIODevice::WriteOnly)) { + downloadInfoLabel->setText(tr("Error opening save file: %1") + .arg(m_output.errorString())); + stopButton->click(); + emit statusChanged(); + return; + } + emit statusChanged(); + } + if (-1 == m_output.write(m_reply->readAll())) { + downloadInfoLabel->setText(tr("Error saving: %1") + .arg(m_output.errorString())); + stopButton->click(); + } +} + +void DownloadItem::error(QNetworkReply::NetworkError) +{ + qDebug() << "DownloadItem::error" << m_reply->errorString() << m_url; + downloadInfoLabel->setText(tr("Network Error: %1").arg(m_reply->errorString())); + tryAgainButton->setEnabled(true); + tryAgainButton->setVisible(true); +} + +void DownloadItem::metaDataChanged() +{ + qDebug() << "DownloadItem::metaDataChanged: not handled."; +} + +void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) +{ + m_bytesReceived = bytesReceived; + if (bytesTotal == -1) { + progressBar->setValue(0); + progressBar->setMaximum(0); + } else { + progressBar->setValue(bytesReceived); + progressBar->setMaximum(bytesTotal); + } + updateInfoLabel(); +} + +void DownloadItem::updateInfoLabel() +{ + if (m_reply->error() == QNetworkReply::NoError) + return; + + qint64 bytesTotal = progressBar->maximum(); + bool running = !downloadedSuccessfully(); + + // update info label + double speed = m_bytesReceived * 1000.0 / m_downloadTime.elapsed(); + double timeRemaining = ((double)(bytesTotal - m_bytesReceived)) / speed; + QString timeRemainingString = tr("seconds"); + if (timeRemaining > 60) { + timeRemaining = timeRemaining / 60; + timeRemainingString = tr("minutes"); + } + timeRemaining = floor(timeRemaining); + + // When downloading the eta should never be 0 + if (timeRemaining == 0) + timeRemaining = 1; + + QString info; + if (running) { + QString remaining; + if (bytesTotal != 0) + remaining = tr("- %4 %5 remaining") + .arg(timeRemaining) + .arg(timeRemainingString); + info = QString(tr("%1 of %2 (%3/sec) %4")) + .arg(dataString(m_bytesReceived)) + .arg(bytesTotal == 0 ? tr("?") : dataString(bytesTotal)) + .arg(dataString((int)speed)) + .arg(remaining); + } else { + if (m_bytesReceived == bytesTotal) + info = dataString(m_output.size()); + else + info = tr("%1 of %2 - Stopped") + .arg(dataString(m_bytesReceived)) + .arg(dataString(bytesTotal)); + } + downloadInfoLabel->setText(info); +} + +QString DownloadItem::dataString(int size) const +{ + QString unit; + if (size < 1024) { + unit = tr("bytes"); + } else if (size < 1024*1024) { + size /= 1024; + unit = tr("kB"); + } else { + size /= 1024*1024; + unit = tr("MB"); + } + return QString(QLatin1String("%1 %2")).arg(size).arg(unit); +} + +bool DownloadItem::downloading() const +{ + return (progressBar->isVisible()); +} + +bool DownloadItem::downloadedSuccessfully() const +{ + return (stopButton->isHidden() && tryAgainButton->isHidden()); +} + +void DownloadItem::finished() +{ + progressBar->hide(); + stopButton->setEnabled(false); + stopButton->hide(); + m_output.close(); + updateInfoLabel(); + emit statusChanged(); +} + +/*! + DownloadManager is a Dialog that contains a list of DownloadItems + + It is a basic download manager. It only downloads the file, doesn't do BitTorrent, + extract zipped files or anything fancy. + */ +DownloadManager::DownloadManager(QWidget *parent) + : QDialog(parent) + , m_autoSaver(new AutoSaver(this)) + , m_manager(BrowserApplication::networkAccessManager()) + , m_iconProvider(0) + , m_removePolicy(Never) +{ + setupUi(this); + downloadsView->setShowGrid(false); + downloadsView->verticalHeader()->hide(); + downloadsView->horizontalHeader()->hide(); + downloadsView->setAlternatingRowColors(true); + downloadsView->horizontalHeader()->setStretchLastSection(true); + m_model = new DownloadModel(this); + downloadsView->setModel(m_model); + connect(cleanupButton, SIGNAL(clicked()), this, SLOT(cleanup())); + load(); +} + +DownloadManager::~DownloadManager() +{ + m_autoSaver->changeOccurred(); + m_autoSaver->saveIfNeccessary(); + if (m_iconProvider) + delete m_iconProvider; +} + +int DownloadManager::activeDownloads() const +{ + int count = 0; + for (int i = 0; i < m_downloads.count(); ++i) { + if (m_downloads.at(i)->stopButton->isEnabled()) + ++count; + } + return count; +} + +void DownloadManager::download(const QNetworkRequest &request, bool requestFileName) +{ + if (request.url().isEmpty()) + return; + handleUnsupportedContent(m_manager->get(request), requestFileName); +} + +void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool requestFileName) +{ + if (!reply || reply->url().isEmpty()) + return; + QVariant header = reply->header(QNetworkRequest::ContentLengthHeader); + bool ok; + int size = header.toInt(&ok); + if (ok && size == 0) + return; + + qDebug() << "DownloadManager::handleUnsupportedContent" << reply->url() << "requestFileName" << requestFileName; + DownloadItem *item = new DownloadItem(reply, requestFileName, this); + addItem(item); +} + +void DownloadManager::addItem(DownloadItem *item) +{ + connect(item, SIGNAL(statusChanged()), this, SLOT(updateRow())); + int row = m_downloads.count(); + m_model->beginInsertRows(QModelIndex(), row, row); + m_downloads.append(item); + m_model->endInsertRows(); + updateItemCount(); + if (row == 0) + show(); + downloadsView->setIndexWidget(m_model->index(row, 0), item); + QIcon icon = style()->standardIcon(QStyle::SP_FileIcon); + item->fileIcon->setPixmap(icon.pixmap(48, 48)); + downloadsView->setRowHeight(row, item->sizeHint().height()); +} + +void DownloadManager::updateRow() +{ + DownloadItem *item = qobject_cast(sender()); + int row = m_downloads.indexOf(item); + if (-1 == row) + return; + if (!m_iconProvider) + m_iconProvider = new QFileIconProvider(); + QIcon icon = m_iconProvider->icon(item->m_output.fileName()); + if (icon.isNull()) + icon = style()->standardIcon(QStyle::SP_FileIcon); + item->fileIcon->setPixmap(icon.pixmap(48, 48)); + downloadsView->setRowHeight(row, item->minimumSizeHint().height()); + + bool remove = false; + QWebSettings *globalSettings = QWebSettings::globalSettings(); + if (!item->downloading() + && globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + remove = true; + + if (item->downloadedSuccessfully() + && removePolicy() == DownloadManager::SuccessFullDownload) { + remove = true; + } + if (remove) + m_model->removeRow(row); + + cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0); +} + +DownloadManager::RemovePolicy DownloadManager::removePolicy() const +{ + return m_removePolicy; +} + +void DownloadManager::setRemovePolicy(RemovePolicy policy) +{ + if (policy == m_removePolicy) + return; + m_removePolicy = policy; + m_autoSaver->changeOccurred(); +} + +void DownloadManager::save() const +{ + QSettings settings; + settings.beginGroup(QLatin1String("downloadmanager")); + QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy")); + settings.setValue(QLatin1String("removeDownloadsPolicy"), QLatin1String(removePolicyEnum.valueToKey(m_removePolicy))); + settings.setValue(QLatin1String("size"), size()); + if (m_removePolicy == Exit) + return; + + for (int i = 0; i < m_downloads.count(); ++i) { + QString key = QString(QLatin1String("download_%1_")).arg(i); + settings.setValue(key + QLatin1String("url"), m_downloads[i]->m_url); + settings.setValue(key + QLatin1String("location"), QFileInfo(m_downloads[i]->m_output).filePath()); + settings.setValue(key + QLatin1String("done"), m_downloads[i]->downloadedSuccessfully()); + } + int i = m_downloads.count(); + QString key = QString(QLatin1String("download_%1_")).arg(i); + while (settings.contains(key + QLatin1String("url"))) { + settings.remove(key + QLatin1String("url")); + settings.remove(key + QLatin1String("location")); + settings.remove(key + QLatin1String("done")); + key = QString(QLatin1String("download_%1_")).arg(++i); + } +} + +void DownloadManager::load() +{ + QSettings settings; + settings.beginGroup(QLatin1String("downloadmanager")); + QSize size = settings.value(QLatin1String("size")).toSize(); + if (size.isValid()) + resize(size); + QByteArray value = settings.value(QLatin1String("removeDownloadsPolicy"), QLatin1String("Never")).toByteArray(); + QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy")); + m_removePolicy = removePolicyEnum.keyToValue(value) == -1 ? + Never : + static_cast(removePolicyEnum.keyToValue(value)); + + int i = 0; + QString key = QString(QLatin1String("download_%1_")).arg(i); + while (settings.contains(key + QLatin1String("url"))) { + QUrl url = settings.value(key + QLatin1String("url")).toUrl(); + QString fileName = settings.value(key + QLatin1String("location")).toString(); + bool done = settings.value(key + QLatin1String("done"), true).toBool(); + if (!url.isEmpty() && !fileName.isEmpty()) { + DownloadItem *item = new DownloadItem(0, this); + item->m_output.setFileName(fileName); + item->fileNameLabel->setText(QFileInfo(item->m_output.fileName()).fileName()); + item->m_url = url; + item->stopButton->setVisible(false); + item->stopButton->setEnabled(false); + item->tryAgainButton->setVisible(!done); + item->tryAgainButton->setEnabled(!done); + item->progressBar->setVisible(!done); + addItem(item); + } + key = QString(QLatin1String("download_%1_")).arg(++i); + } + cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0); +} + +void DownloadManager::cleanup() +{ + if (m_downloads.isEmpty()) + return; + m_model->removeRows(0, m_downloads.count()); + updateItemCount(); + if (m_downloads.isEmpty() && m_iconProvider) { + delete m_iconProvider; + m_iconProvider = 0; + } + m_autoSaver->changeOccurred(); +} + +void DownloadManager::updateItemCount() +{ + int count = m_downloads.count(); + itemCount->setText(count == 1 ? tr("1 Download") : tr("%1 Downloads").arg(count)); +} + +DownloadModel::DownloadModel(DownloadManager *downloadManager, QObject *parent) + : QAbstractListModel(parent) + , m_downloadManager(downloadManager) +{ +} + +QVariant DownloadModel::data(const QModelIndex &index, int role) const +{ + if (index.row() < 0 || index.row() >= rowCount(index.parent())) + return QVariant(); + if (role == Qt::ToolTipRole) + if (!m_downloadManager->m_downloads.at(index.row())->downloadedSuccessfully()) + return m_downloadManager->m_downloads.at(index.row())->downloadInfoLabel->text(); + return QVariant(); +} + +int DownloadModel::rowCount(const QModelIndex &parent) const +{ + return (parent.isValid()) ? 0 : m_downloadManager->m_downloads.count(); +} + +bool DownloadModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (parent.isValid()) + return false; + + int lastRow = row + count - 1; + for (int i = lastRow; i >= row; --i) { + if (m_downloadManager->m_downloads.at(i)->downloadedSuccessfully() + || m_downloadManager->m_downloads.at(i)->tryAgainButton->isEnabled()) { + beginRemoveRows(parent, i, i); + m_downloadManager->m_downloads.takeAt(i)->deleteLater(); + endRemoveRows(); + } + } + m_downloadManager->m_autoSaver->changeOccurred(); + return true; +} + diff --git a/src/downloadmanager.h b/src/downloadmanager.h new file mode 100644 index 00000000..6f27622b --- /dev/null +++ b/src/downloadmanager.h @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef DOWNLOADMANAGER_H +#define DOWNLOADMANAGER_H + +#include "ui_downloads.h" +#include "ui_downloaditem.h" + +#include + +#include +#include + +class DownloadItem : public QWidget, public Ui_DownloadItem +{ + Q_OBJECT + +signals: + void statusChanged(); + +public: + DownloadItem(QNetworkReply *reply = 0, bool requestFileName = false, QWidget *parent = 0); + bool downloading() const; + bool downloadedSuccessfully() const; + + QUrl m_url; + + QFile m_output; + QNetworkReply *m_reply; + +private slots: + void stop(); + void tryAgain(); + void open(); + + void downloadReadyRead(); + void error(QNetworkReply::NetworkError code); + void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); + void metaDataChanged(); + void finished(); + +private: + void getFileName(); + void init(); + void updateInfoLabel(); + QString dataString(int size) const; + + QString saveFileName(const QString &directory) const; + + bool m_requestFileName; + qint64 m_bytesReceived; + QTime m_downloadTime; +}; + +class AutoSaver; +class DownloadModel; +QT_BEGIN_NAMESPACE +class QFileIconProvider; +QT_END_NAMESPACE + +class DownloadManager : public QDialog, public Ui_DownloadDialog +{ + Q_OBJECT + Q_PROPERTY(RemovePolicy removePolicy READ removePolicy WRITE setRemovePolicy) + Q_ENUMS(RemovePolicy) + +public: + enum RemovePolicy { + Never, + Exit, + SuccessFullDownload + }; + + DownloadManager(QWidget *parent = 0); + ~DownloadManager(); + int activeDownloads() const; + + RemovePolicy removePolicy() const; + void setRemovePolicy(RemovePolicy policy); + +public slots: + void download(const QNetworkRequest &request, bool requestFileName = false); + inline void download(const QUrl &url, bool requestFileName = false) + { download(QNetworkRequest(url), requestFileName); } + void handleUnsupportedContent(QNetworkReply *reply, bool requestFileName = false); + void cleanup(); + +private slots: + void save() const; + void updateRow(); + +private: + void addItem(DownloadItem *item); + void updateItemCount(); + void load(); + + AutoSaver *m_autoSaver; + DownloadModel *m_model; + QNetworkAccessManager *m_manager; + QFileIconProvider *m_iconProvider; + QList m_downloads; + RemovePolicy m_removePolicy; + friend class DownloadModel; +}; + +class DownloadModel : public QAbstractListModel +{ + friend class DownloadManager; + Q_OBJECT + +public: + DownloadModel(DownloadManager *downloadManager, QObject *parent = 0); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + +private: + DownloadManager *m_downloadManager; + +}; + +#endif // DOWNLOADMANAGER_H + diff --git a/src/downloads.ui b/src/downloads.ui new file mode 100644 index 00000000..a2e25693 --- /dev/null +++ b/src/downloads.ui @@ -0,0 +1,83 @@ + + DownloadDialog + + + + 0 + 0 + 332 + 252 + + + + Downloads + + + + 0 + + + 0 + + + + + + + + + + false + + + Clean up + + + + + + + Qt::Horizontal + + + + 58 + 24 + + + + + + + + + + 0 Items + + + + + + + Qt::Horizontal + + + + 148 + 20 + + + + + + + + + EditTableView + QTableView +
edittableview.h
+
+
+ + +
diff --git a/src/edittableview.cpp b/src/edittableview.cpp new file mode 100644 index 00000000..d47ac78b --- /dev/null +++ b/src/edittableview.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "edittableview.h" +#include + +EditTableView::EditTableView(QWidget *parent) + : QTableView(parent) +{ +} + +void EditTableView::keyPressEvent(QKeyEvent *event) +{ + if ((event->key() == Qt::Key_Delete + || event->key() == Qt::Key_Backspace) + && model()) { + removeOne(); + } else { + QAbstractItemView::keyPressEvent(event); + } +} + +void EditTableView::removeOne() +{ + if (!model() || !selectionModel()) + return; + int row = currentIndex().row(); + model()->removeRow(row, rootIndex()); + QModelIndex idx = model()->index(row, 0, rootIndex()); + if (!idx.isValid()) + idx = model()->index(row - 1, 0, rootIndex()); + selectionModel()->select(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); +} + +void EditTableView::removeAll() +{ + if (model()) + model()->removeRows(0, model()->rowCount(rootIndex()), rootIndex()); +} diff --git a/src/edittableview.h b/src/edittableview.h new file mode 100644 index 00000000..f22c3ce9 --- /dev/null +++ b/src/edittableview.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef EDITTABLEVIEW_H +#define EDITTABLEVIEW_H + +#include + +class EditTableView : public QTableView +{ + Q_OBJECT + +public: + EditTableView(QWidget *parent = 0); + void keyPressEvent(QKeyEvent *event); + +public slots: + void removeOne(); + void removeAll(); +}; + +#endif // EDITTABLEVIEW_H + diff --git a/src/edittreeview.cpp b/src/edittreeview.cpp new file mode 100644 index 00000000..5e55fd16 --- /dev/null +++ b/src/edittreeview.cpp @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "edittreeview.h" + +#include + +EditTreeView::EditTreeView(QWidget *parent) + : QTreeView(parent) +{ +} + +void EditTreeView::keyPressEvent(QKeyEvent *event) +{ + if ((event->key() == Qt::Key_Delete + || event->key() == Qt::Key_Backspace) + && model()) { + removeOne(); + } else { + QAbstractItemView::keyPressEvent(event); + } +} + +void EditTreeView::removeOne() +{ + if (!model()) + return; + QModelIndex ci = currentIndex(); + int row = ci.row(); + model()->removeRow(row, ci.parent()); +} + +void EditTreeView::removeAll() +{ + if (!model()) + return; + model()->removeRows(0, model()->rowCount(rootIndex()), rootIndex()); +} + diff --git a/src/edittreeview.h b/src/edittreeview.h new file mode 100644 index 00000000..1341ad62 --- /dev/null +++ b/src/edittreeview.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef EDITTREEVIEW_H +#define EDITTREEVIEW_H + +#include + +class EditTreeView : public QTreeView +{ + Q_OBJECT + +public: + EditTreeView(QWidget *parent = 0); + void keyPressEvent(QKeyEvent *event); + +public slots: + void removeOne(); + void removeAll(); +}; + +#endif // EDITTREEVIEW_H + diff --git a/src/history.cpp b/src/history.cpp new file mode 100644 index 00000000..fef1920c --- /dev/null +++ b/src/history.cpp @@ -0,0 +1,1277 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "history.h" + +#include "autosaver.h" +#include "browserapplication.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#include + +static const unsigned int HISTORY_VERSION = 23; + +HistoryManager::HistoryManager(QObject *parent) + : QWebHistoryInterface(parent) + , m_saveTimer(new AutoSaver(this)) + , m_historyLimit(30) + , m_historyModel(0) + , m_historyFilterModel(0) + , m_historyTreeModel(0) +{ + m_expiredTimer.setSingleShot(true); + connect(&m_expiredTimer, SIGNAL(timeout()), + this, SLOT(checkForExpired())); + connect(this, SIGNAL(entryAdded(const HistoryItem &)), + m_saveTimer, SLOT(changeOccurred())); + connect(this, SIGNAL(entryRemoved(const HistoryItem &)), + m_saveTimer, SLOT(changeOccurred())); + load(); + + m_historyModel = new HistoryModel(this, this); + m_historyFilterModel = new HistoryFilterModel(m_historyModel, this); + m_historyTreeModel = new HistoryTreeModel(m_historyFilterModel, this); + + // QWebHistoryInterface will delete the history manager + QWebHistoryInterface::setDefaultInterface(this); +} + +HistoryManager::~HistoryManager() +{ + m_saveTimer->saveIfNeccessary(); +} + +QList HistoryManager::history() const +{ + return m_history; +} + +bool HistoryManager::historyContains(const QString &url) const +{ + return m_historyFilterModel->historyContains(url); +} + +void HistoryManager::addHistoryEntry(const QString &url) +{ + QUrl cleanUrl(url); + cleanUrl.setPassword(QString()); + cleanUrl.setHost(cleanUrl.host().toLower()); + HistoryItem item(cleanUrl.toString(), QDateTime::currentDateTime()); + addHistoryItem(item); +} + +void HistoryManager::setHistory(const QList &history, bool loadedAndSorted) +{ + m_history = history; + + // verify that it is sorted by date + if (!loadedAndSorted) + qSort(m_history.begin(), m_history.end()); + + checkForExpired(); + + if (loadedAndSorted) { + m_lastSavedUrl = m_history.value(0).url; + } else { + m_lastSavedUrl = QString(); + m_saveTimer->changeOccurred(); + } + emit historyReset(); +} + +HistoryModel *HistoryManager::historyModel() const +{ + return m_historyModel; +} + +HistoryFilterModel *HistoryManager::historyFilterModel() const +{ + return m_historyFilterModel; +} + +HistoryTreeModel *HistoryManager::historyTreeModel() const +{ + return m_historyTreeModel; +} + +void HistoryManager::checkForExpired() +{ + if (m_historyLimit < 0 || m_history.isEmpty()) + return; + + QDateTime now = QDateTime::currentDateTime(); + int nextTimeout = 0; + + while (!m_history.isEmpty()) { + QDateTime checkForExpired = m_history.last().dateTime; + checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit)); + if (now.daysTo(checkForExpired) > 7) { + // check at most in a week to prevent int overflows on the timer + nextTimeout = 7 * 86400; + } else { + nextTimeout = now.secsTo(checkForExpired); + } + if (nextTimeout > 0) + break; + HistoryItem item = m_history.takeLast(); + // remove from saved file also + m_lastSavedUrl = QString(); + emit entryRemoved(item); + } + + if (nextTimeout > 0) + m_expiredTimer.start(nextTimeout * 1000); +} + +void HistoryManager::addHistoryItem(const HistoryItem &item) +{ + QWebSettings *globalSettings = QWebSettings::globalSettings(); + if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + return; + + m_history.prepend(item); + emit entryAdded(item); + if (m_history.count() == 1) + checkForExpired(); +} + +void HistoryManager::updateHistoryItem(const QUrl &url, const QString &title) +{ + for (int i = 0; i < m_history.count(); ++i) { + if (url == m_history.at(i).url) { + m_history[i].title = title; + m_saveTimer->changeOccurred(); + if (m_lastSavedUrl.isEmpty()) + m_lastSavedUrl = m_history.at(i).url; + emit entryUpdated(i); + break; + } + } +} + +int HistoryManager::historyLimit() const +{ + return m_historyLimit; +} + +void HistoryManager::setHistoryLimit(int limit) +{ + if (m_historyLimit == limit) + return; + m_historyLimit = limit; + checkForExpired(); + m_saveTimer->changeOccurred(); +} + +void HistoryManager::clear() +{ + m_history.clear(); + m_lastSavedUrl = QString(); + m_saveTimer->changeOccurred(); + m_saveTimer->saveIfNeccessary(); + historyReset(); +} + +void HistoryManager::loadSettings() +{ + // load settings + QSettings settings; + settings.beginGroup(QLatin1String("history")); + m_historyLimit = settings.value(QLatin1String("historyLimit"), 30).toInt(); +} + +void HistoryManager::load() +{ + loadSettings(); + + QFile historyFile(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + + QLatin1String("/history")); + if (!historyFile.exists()) + return; + if (!historyFile.open(QFile::ReadOnly)) { + qWarning() << "Unable to open history file" << historyFile.fileName(); + return; + } + + QList list; + QDataStream in(&historyFile); + // Double check that the history file is sorted as it is read in + bool needToSort = false; + HistoryItem lastInsertedItem; + QByteArray data; + QDataStream stream; + QBuffer buffer; + stream.setDevice(&buffer); + while (!historyFile.atEnd()) { + in >> data; + buffer.close(); + buffer.setBuffer(&data); + buffer.open(QIODevice::ReadOnly); + quint32 ver; + stream >> ver; + if (ver != HISTORY_VERSION) + continue; + HistoryItem item; + stream >> item.url; + stream >> item.dateTime; + stream >> item.title; + + if (!item.dateTime.isValid()) + continue; + + if (item == lastInsertedItem) { + if (lastInsertedItem.title.isEmpty() && !list.isEmpty()) + list[0].title = item.title; + continue; + } + + if (!needToSort && !list.isEmpty() && lastInsertedItem < item) + needToSort = true; + + list.prepend(item); + lastInsertedItem = item; + } + if (needToSort) + qSort(list.begin(), list.end()); + + setHistory(list, true); + + // If we had to sort re-write the whole history sorted + if (needToSort) { + m_lastSavedUrl = QString(); + m_saveTimer->changeOccurred(); + } +} + +void HistoryManager::save() +{ + QSettings settings; + settings.beginGroup(QLatin1String("history")); + settings.setValue(QLatin1String("historyLimit"), m_historyLimit); + + bool saveAll = m_lastSavedUrl.isEmpty(); + int first = m_history.count() - 1; + if (!saveAll) { + // find the first one to save + for (int i = 0; i < m_history.count(); ++i) { + if (m_history.at(i).url == m_lastSavedUrl) { + first = i - 1; + break; + } + } + } + if (first == m_history.count() - 1) + saveAll = true; + + QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + if (directory.isEmpty()) + directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); + if (!QFile::exists(directory)) { + QDir dir; + dir.mkpath(directory); + } + + QFile historyFile(directory + QLatin1String("/history")); + // When saving everything use a temporary file to prevent possible data loss. + QTemporaryFile tempFile; + tempFile.setAutoRemove(false); + bool open = false; + if (saveAll) { + open = tempFile.open(); + } else { + open = historyFile.open(QFile::Append); + } + + if (!open) { + qWarning() << "Unable to open history file for saving" + << (saveAll ? tempFile.fileName() : historyFile.fileName()); + return; + } + + QDataStream out(saveAll ? &tempFile : &historyFile); + for (int i = first; i >= 0; --i) { + QByteArray data; + QDataStream stream(&data, QIODevice::WriteOnly); + HistoryItem item = m_history.at(i); + stream << HISTORY_VERSION << item.url << item.dateTime << item.title; + out << data; + } + tempFile.close(); + + if (saveAll) { + if (historyFile.exists() && !historyFile.remove()) + qWarning() << "History: error removing old history." << historyFile.errorString(); + if (!tempFile.rename(historyFile.fileName())) + qWarning() << "History: error moving new history over old." << tempFile.errorString() << historyFile.fileName(); + } + m_lastSavedUrl = m_history.value(0).url; +} + +HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) + : QAbstractTableModel(parent) + , m_history(history) +{ + Q_ASSERT(m_history); + connect(m_history, SIGNAL(historyReset()), + this, SLOT(historyReset())); + connect(m_history, SIGNAL(entryRemoved(const HistoryItem &)), + this, SLOT(historyReset())); + + connect(m_history, SIGNAL(entryAdded(const HistoryItem &)), + this, SLOT(entryAdded())); + connect(m_history, SIGNAL(entryUpdated(int)), + this, SLOT(entryUpdated(int))); +} + +void HistoryModel::historyReset() +{ + reset(); +} + +void HistoryModel::entryAdded() +{ + beginInsertRows(QModelIndex(), 0, 0); + endInsertRows(); +} + +void HistoryModel::entryUpdated(int offset) +{ + QModelIndex idx = index(offset, 0); + emit dataChanged(idx, idx); +} + +QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (orientation == Qt::Horizontal + && role == Qt::DisplayRole) { + switch (section) { + case 0: return tr("Title"); + case 1: return tr("Address"); + } + } + return QAbstractTableModel::headerData(section, orientation, role); +} + +QVariant HistoryModel::data(const QModelIndex &index, int role) const +{ + QList lst = m_history->history(); + if (index.row() < 0 || index.row() >= lst.size()) + return QVariant(); + + const HistoryItem &item = lst.at(index.row()); + switch (role) { + case DateTimeRole: + return item.dateTime; + case DateRole: + return item.dateTime.date(); + case UrlRole: + return QUrl(item.url); + case UrlStringRole: + return item.url; + case Qt::DisplayRole: + case Qt::EditRole: { + switch (index.column()) { + case 0: + // when there is no title try to generate one from the url + if (item.title.isEmpty()) { + QString page = QFileInfo(QUrl(item.url).path()).fileName(); + if (!page.isEmpty()) + return page; + return item.url; + } + return item.title; + case 1: + return item.url; + } + } + case Qt::DecorationRole: + if (index.column() == 0) { + return BrowserApplication::instance()->icon(item.url); + } + } + return QVariant(); +} + +int HistoryModel::columnCount(const QModelIndex &parent) const +{ + return (parent.isValid()) ? 0 : 2; +} + +int HistoryModel::rowCount(const QModelIndex &parent) const +{ + return (parent.isValid()) ? 0 : m_history->history().count(); +} + +bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (parent.isValid()) + return false; + int lastRow = row + count - 1; + beginRemoveRows(parent, row, lastRow); + QList lst = m_history->history(); + for (int i = lastRow; i >= row; --i) + lst.removeAt(i); + disconnect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset())); + m_history->setHistory(lst); + connect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset())); + endRemoveRows(); + return true; +} + +#define MOVEDROWS 15 + +/* + Maps the first bunch of items of the source model to the root +*/ +HistoryMenuModel::HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent) + : QAbstractProxyModel(parent) + , m_treeModel(sourceModel) +{ + setSourceModel(sourceModel); +} + +int HistoryMenuModel::bumpedRows() const +{ + QModelIndex first = m_treeModel->index(0, 0); + if (!first.isValid()) + return 0; + return qMin(m_treeModel->rowCount(first), MOVEDROWS); +} + +int HistoryMenuModel::columnCount(const QModelIndex &parent) const +{ + return m_treeModel->columnCount(mapToSource(parent)); +} + +int HistoryMenuModel::rowCount(const QModelIndex &parent) const +{ + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) { + int folders = sourceModel()->rowCount(); + int bumpedItems = bumpedRows(); + if (bumpedItems <= MOVEDROWS + && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0))) + --folders; + return bumpedItems + folders; + } + + if (parent.internalId() == -1) { + if (parent.row() < bumpedRows()) + return 0; + } + + QModelIndex idx = mapToSource(parent); + int defaultCount = sourceModel()->rowCount(idx); + if (idx == sourceModel()->index(0, 0)) + return defaultCount - bumpedRows(); + return defaultCount; +} + +QModelIndex HistoryMenuModel::mapFromSource(const QModelIndex &sourceIndex) const +{ + // currently not used or autotested + Q_ASSERT(false); + int sr = m_treeModel->mapToSource(sourceIndex).row(); + return createIndex(sourceIndex.row(), sourceIndex.column(), sr); +} + +QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const +{ + if (!proxyIndex.isValid()) + return QModelIndex(); + + if (proxyIndex.internalId() == -1) { + int bumpedItems = bumpedRows(); + if (proxyIndex.row() < bumpedItems) + return m_treeModel->index(proxyIndex.row(), proxyIndex.column(), m_treeModel->index(0, 0)); + if (bumpedItems <= MOVEDROWS && bumpedItems == sourceModel()->rowCount(m_treeModel->index(0, 0))) + --bumpedItems; + return m_treeModel->index(proxyIndex.row() - bumpedItems, proxyIndex.column()); + } + + QModelIndex historyIndex = m_treeModel->sourceModel()->index(proxyIndex.internalId(), proxyIndex.column()); + QModelIndex treeIndex = m_treeModel->mapFromSource(historyIndex); + return treeIndex; +} + +QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &parent) const +{ + if (row < 0 + || column < 0 || column >= columnCount(parent) + || parent.column() > 0) + return QModelIndex(); + if (!parent.isValid()) + return createIndex(row, column, -1); + + QModelIndex treeIndexParent = mapToSource(parent); + + int bumpedItems = 0; + if (treeIndexParent == m_treeModel->index(0, 0)) + bumpedItems = bumpedRows(); + QModelIndex treeIndex = m_treeModel->index(row + bumpedItems, column, treeIndexParent); + QModelIndex historyIndex = m_treeModel->mapToSource(treeIndex); + int historyRow = historyIndex.row(); + if (historyRow == -1) + historyRow = treeIndex.row(); + return createIndex(row, column, historyRow); +} + +QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const +{ + int offset = index.internalId(); + if (offset == -1 || !index.isValid()) + return QModelIndex(); + + QModelIndex historyIndex = m_treeModel->sourceModel()->index(index.internalId(), 0); + QModelIndex treeIndex = m_treeModel->mapFromSource(historyIndex); + QModelIndex treeIndexParent = treeIndex.parent(); + + int sr = m_treeModel->mapToSource(treeIndexParent).row(); + int bumpedItems = bumpedRows(); + if (bumpedItems <= MOVEDROWS && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0))) + --bumpedItems; + return createIndex(bumpedItems + treeIndexParent.row(), treeIndexParent.column(), sr); +} + + +HistoryMenu::HistoryMenu(QWidget *parent) + : ModelMenu(parent) + , m_history(0) +{ + connect(this, SIGNAL(activated(const QModelIndex &)), + this, SLOT(activated(const QModelIndex &))); + setHoverRole(HistoryModel::UrlStringRole); +} + +void HistoryMenu::activated(const QModelIndex &index) +{ + emit openUrl(index.data(HistoryModel::UrlRole).toUrl()); +} + +bool HistoryMenu::prePopulated() +{ + if (!m_history) { + m_history = BrowserApplication::historyManager(); + m_historyMenuModel = new HistoryMenuModel(m_history->historyTreeModel(), this); + setModel(m_historyMenuModel); + } + // initial actions + for (int i = 0; i < m_initialActions.count(); ++i) + addAction(m_initialActions.at(i)); + if (!m_initialActions.isEmpty()) + addSeparator(); + setFirstSeparator(m_historyMenuModel->bumpedRows()); + + return false; +} + +void HistoryMenu::postPopulated() +{ + if (m_history->history().count() > 0) + addSeparator(); + + QAction *showAllAction = new QAction(tr("Show All History"), this); + connect(showAllAction, SIGNAL(triggered()), this, SLOT(showHistoryDialog())); + addAction(showAllAction); + + QAction *clearAction = new QAction(tr("Clear History"), this); + connect(clearAction, SIGNAL(triggered()), m_history, SLOT(clear())); + addAction(clearAction); +} + +void HistoryMenu::showHistoryDialog() +{ + HistoryDialog *dialog = new HistoryDialog(this); + connect(dialog, SIGNAL(openUrl(const QUrl&)), + this, SIGNAL(openUrl(const QUrl&))); + dialog->show(); +} + +void HistoryMenu::setInitialActions(QList actions) +{ + m_initialActions = actions; + for (int i = 0; i < m_initialActions.count(); ++i) + addAction(m_initialActions.at(i)); +} + +TreeProxyModel::TreeProxyModel(QObject *parent) : QSortFilterProxyModel(parent) +{ + setSortRole(HistoryModel::DateTimeRole); + setFilterCaseSensitivity(Qt::CaseInsensitive); +} + +bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const +{ + if (!source_parent.isValid()) + return true; + return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); +} + +HistoryDialog::HistoryDialog(QWidget *parent, HistoryManager *setHistory) : QDialog(parent) +{ + HistoryManager *history = setHistory; + if (!history) + history = BrowserApplication::historyManager(); + setupUi(this); + tree->setUniformRowHeights(true); + tree->setSelectionBehavior(QAbstractItemView::SelectRows); + tree->setTextElideMode(Qt::ElideMiddle); + QAbstractItemModel *model = history->historyTreeModel(); + TreeProxyModel *proxyModel = new TreeProxyModel(this); + connect(search, SIGNAL(textChanged(QString)), + proxyModel, SLOT(setFilterFixedString(QString))); + connect(removeButton, SIGNAL(clicked()), tree, SLOT(removeOne())); + connect(removeAllButton, SIGNAL(clicked()), history, SLOT(clear())); + proxyModel->setSourceModel(model); + tree->setModel(proxyModel); + tree->setExpanded(proxyModel->index(0, 0), true); + tree->setAlternatingRowColors(true); + QFontMetrics fm(font()); + int header = fm.width(QLatin1Char('m')) * 40; + tree->header()->resizeSection(0, header); + tree->header()->setStretchLastSection(true); + connect(tree, SIGNAL(activated(const QModelIndex&)), + this, SLOT(open())); + tree->setContextMenuPolicy(Qt::CustomContextMenu); + connect(tree, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(customContextMenuRequested(const QPoint &))); +} + +void HistoryDialog::customContextMenuRequested(const QPoint &pos) +{ + QMenu menu; + QModelIndex index = tree->indexAt(pos); + index = index.sibling(index.row(), 0); + if (index.isValid() && !tree->model()->hasChildren(index)) { + menu.addAction(tr("Open"), this, SLOT(open())); + menu.addSeparator(); + menu.addAction(tr("Copy"), this, SLOT(copy())); + } + menu.addAction(tr("Delete"), tree, SLOT(removeOne())); + menu.exec(QCursor::pos()); +} + +void HistoryDialog::open() +{ + QModelIndex index = tree->currentIndex(); + if (!index.parent().isValid()) + return; + emit openUrl(index.data(HistoryModel::UrlRole).toUrl()); +} + +void HistoryDialog::copy() +{ + QModelIndex index = tree->currentIndex(); + if (!index.parent().isValid()) + return; + QString url = index.data(HistoryModel::UrlStringRole).toString(); + + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText(url); +} + +HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent) + : QAbstractProxyModel(parent), + m_loaded(false) +{ + setSourceModel(sourceModel); +} + +int HistoryFilterModel::historyLocation(const QString &url) const +{ + load(); + if (!m_historyHash.contains(url)) + return 0; + return sourceModel()->rowCount() - m_historyHash.value(url); +} + +QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const +{ + return QAbstractProxyModel::data(index, role); +} + +void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) +{ + if (sourceModel()) { + disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); + disconnect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + this, SLOT(dataChanged(const QModelIndex &, const QModelIndex &))); + disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + } + + QAbstractProxyModel::setSourceModel(newSourceModel); + + if (sourceModel()) { + m_loaded = false; + connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); + connect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &))); + connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + } +} + +void HistoryFilterModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight)); +} + +QVariant HistoryFilterModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + return sourceModel()->headerData(section, orientation, role); +} + +void HistoryFilterModel::sourceReset() +{ + m_loaded = false; + reset(); +} + +int HistoryFilterModel::rowCount(const QModelIndex &parent) const +{ + load(); + if (parent.isValid()) + return 0; + return m_historyHash.count(); +} + +int HistoryFilterModel::columnCount(const QModelIndex &parent) const +{ + return (parent.isValid()) ? 0 : 2; +} + +QModelIndex HistoryFilterModel::mapToSource(const QModelIndex &proxyIndex) const +{ + load(); + int sourceRow = sourceModel()->rowCount() - proxyIndex.internalId(); + return sourceModel()->index(sourceRow, proxyIndex.column()); +} + +QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) const +{ + load(); + QString url = sourceIndex.data(HistoryModel::UrlStringRole).toString(); + if (!m_historyHash.contains(url)) + return QModelIndex(); + + // This can be done in a binary search, but we can't use qBinary find + // because it can't take: qBinaryFind(m_sourceRow.end(), m_sourceRow.begin(), v); + // so if this is a performance bottlneck then convert to binary search, until then + // the cleaner/easier to read code wins the day. + int realRow = -1; + int sourceModelRow = sourceModel()->rowCount() - sourceIndex.row(); + + for (int i = 0; i < m_sourceRow.count(); ++i) { + if (m_sourceRow.at(i) == sourceModelRow) { + realRow = i; + break; + } + } + if (realRow == -1) + return QModelIndex(); + + return createIndex(realRow, sourceIndex.column(), sourceModel()->rowCount() - sourceIndex.row()); +} + +QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &parent) const +{ + load(); + if (row < 0 || row >= rowCount(parent) + || column < 0 || column >= columnCount(parent)) + return QModelIndex(); + + return createIndex(row, column, m_sourceRow[row]); +} + +QModelIndex HistoryFilterModel::parent(const QModelIndex &) const +{ + return QModelIndex(); +} + +void HistoryFilterModel::load() const +{ + if (m_loaded) + return; + m_sourceRow.clear(); + m_historyHash.clear(); + m_historyHash.reserve(sourceModel()->rowCount()); + for (int i = 0; i < sourceModel()->rowCount(); ++i) { + QModelIndex idx = sourceModel()->index(i, 0); + QString url = idx.data(HistoryModel::UrlStringRole).toString(); + if (!m_historyHash.contains(url)) { + m_sourceRow.append(sourceModel()->rowCount() - i); + m_historyHash[url] = sourceModel()->rowCount() - i; + } + } + m_loaded = true; +} + +void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start, int end) +{ + Q_ASSERT(start == end && start == 0); + Q_UNUSED(end); + if (!m_loaded) + return; + QModelIndex idx = sourceModel()->index(start, 0, parent); + QString url = idx.data(HistoryModel::UrlStringRole).toString(); + if (m_historyHash.contains(url)) { + int sourceRow = sourceModel()->rowCount() - m_historyHash[url]; + int realRow = mapFromSource(sourceModel()->index(sourceRow, 0)).row(); + beginRemoveRows(QModelIndex(), realRow, realRow); + m_sourceRow.removeAt(realRow); + m_historyHash.remove(url); + endRemoveRows(); + } + beginInsertRows(QModelIndex(), 0, 0); + m_historyHash.insert(url, sourceModel()->rowCount() - start); + m_sourceRow.insert(0, sourceModel()->rowCount()); + endInsertRows(); +} + +void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int end) +{ + Q_UNUSED(start); + Q_UNUSED(end); + sourceReset(); +} + +/* + Removing a continuous block of rows will remove filtered rows too as this is + the users intention. +*/ +bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (row < 0 || count <= 0 || row + count > rowCount(parent) || parent.isValid()) + return false; + int lastRow = row + count - 1; + disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + beginRemoveRows(parent, row, lastRow); + int oldCount = rowCount(); + int start = sourceModel()->rowCount() - m_sourceRow.value(row); + int end = sourceModel()->rowCount() - m_sourceRow.value(lastRow); + sourceModel()->removeRows(start, end - start + 1); + endRemoveRows(); + connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + m_loaded = false; + if (oldCount - count != rowCount()) + reset(); + return true; +} + +HistoryCompletionModel::HistoryCompletionModel(QObject *parent) + : QAbstractProxyModel(parent) +{ +} + +QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const +{ + if (sourceModel() + && (role == Qt::EditRole || role == Qt::DisplayRole) + && index.isValid()) { + QModelIndex idx = mapToSource(index); + idx = idx.sibling(idx.row(), 1); + QString urlString = idx.data(HistoryModel::UrlStringRole).toString(); + if (index.row() % 2) { + QUrl url = urlString; + QString s = url.toString(QUrl::RemoveScheme + | QUrl::RemoveUserInfo + | QUrl::StripTrailingSlash); + return s.mid(2); // strip // from the front + } + return urlString; + } + return QAbstractProxyModel::data(index, role); +} + +int HistoryCompletionModel::rowCount(const QModelIndex &parent) const +{ + return (parent.isValid() || !sourceModel()) ? 0 : sourceModel()->rowCount(parent) * 2; +} + +int HistoryCompletionModel::columnCount(const QModelIndex &parent) const +{ + return (parent.isValid()) ? 0 : 1; +} + +QModelIndex HistoryCompletionModel::mapFromSource(const QModelIndex &sourceIndex) const +{ + int row = sourceIndex.row() * 2; + return index(row, sourceIndex.column()); +} + +QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) const +{ + if (!sourceModel()) + return QModelIndex(); + int row = proxyIndex.row() / 2; + return sourceModel()->index(row, proxyIndex.column()); +} + +QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex &parent) const +{ + if (row < 0 || row >= rowCount(parent) + || column < 0 || column >= columnCount(parent)) + return QModelIndex(); + return createIndex(row, column, 0); +} + +QModelIndex HistoryCompletionModel::parent(const QModelIndex &) const +{ + return QModelIndex(); +} + +void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) +{ + if (sourceModel()) { + disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); + disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(sourceReset())); + disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceReset())); + } + + QAbstractProxyModel::setSourceModel(newSourceModel); + + if (newSourceModel) { + connect(newSourceModel, SIGNAL(modelReset()), this, SLOT(sourceReset())); + connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(sourceReset())); + connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceReset())); + } + + reset(); +} + +void HistoryCompletionModel::sourceReset() +{ + reset(); +} + +HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent) + : QAbstractProxyModel(parent) +{ + setSourceModel(sourceModel); +} + +QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + return sourceModel()->headerData(section, orientation, role); +} + +QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const +{ + if ((role == Qt::EditRole || role == Qt::DisplayRole)) { + int start = index.internalId(); + if (start == 0) { + int offset = sourceDateRow(index.row()); + if (index.column() == 0) { + QModelIndex idx = sourceModel()->index(offset, 0); + QDate date = idx.data(HistoryModel::DateRole).toDate(); + if (date == QDate::currentDate()) + return tr("Earlier Today"); + return date.toString(QLatin1String("dddd, MMMM d, yyyy")); + } + if (index.column() == 1) { + return tr("%1 items").arg(rowCount(index.sibling(index.row(), 0))); + } + } + } + if (role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid()) + return QIcon(QLatin1String(":history.png")); + if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) { + int offset = sourceDateRow(index.row()); + QModelIndex idx = sourceModel()->index(offset, 0); + return idx.data(HistoryModel::DateRole); + } + + return QAbstractProxyModel::data(index, role); +} + +int HistoryTreeModel::columnCount(const QModelIndex &parent) const +{ + return sourceModel()->columnCount(mapToSource(parent)); +} + +int HistoryTreeModel::rowCount(const QModelIndex &parent) const +{ + if ( parent.internalId() != 0 + || parent.column() > 0 + || !sourceModel()) + return 0; + + // row count OF dates + if (!parent.isValid()) { + if (!m_sourceRowCache.isEmpty()) + return m_sourceRowCache.count(); + QDate currentDate; + int rows = 0; + int totalRows = sourceModel()->rowCount(); + + for (int i = 0; i < totalRows; ++i) { + QDate rowDate = sourceModel()->index(i, 0).data(HistoryModel::DateRole).toDate(); + if (rowDate != currentDate) { + m_sourceRowCache.append(i); + currentDate = rowDate; + ++rows; + } + } + Q_ASSERT(m_sourceRowCache.count() == rows); + return rows; + } + + // row count FOR a date + int start = sourceDateRow(parent.row()); + int end = sourceDateRow(parent.row() + 1); + return (end - start); +} + +// Translate the top level date row into the offset where that date starts +int HistoryTreeModel::sourceDateRow(int row) const +{ + if (row <= 0) + return 0; + + if (m_sourceRowCache.isEmpty()) + rowCount(QModelIndex()); + + if (row >= m_sourceRowCache.count()) { + if (!sourceModel()) + return 0; + return sourceModel()->rowCount(); + } + return m_sourceRowCache.at(row); +} + +QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const +{ + int offset = proxyIndex.internalId(); + if (offset == 0) + return QModelIndex(); + int startDateRow = sourceDateRow(offset - 1); + return sourceModel()->index(startDateRow + proxyIndex.row(), proxyIndex.column()); +} + +QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const +{ + if (row < 0 + || column < 0 || column >= columnCount(parent) + || parent.column() > 0) + return QModelIndex(); + + if (!parent.isValid()) + return createIndex(row, column, 0); + return createIndex(row, column, parent.row() + 1); +} + +QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const +{ + int offset = index.internalId(); + if (offset == 0 || !index.isValid()) + return QModelIndex(); + return createIndex(offset - 1, 0, 0); +} + +bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const +{ + QModelIndex grandparent = parent.parent(); + if (!grandparent.isValid()) + return true; + return false; +} + +Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled; +} + +bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (row < 0 || count <= 0 || row + count > rowCount(parent)) + return false; + + if (parent.isValid()) { + // removing pages + int offset = sourceDateRow(parent.row()); + return sourceModel()->removeRows(offset + row, count); + } else { + // removing whole dates + for (int i = row + count - 1; i >= row; --i) { + QModelIndex dateParent = index(i, 0); + int offset = sourceDateRow(dateParent.row()); + if (!sourceModel()->removeRows(offset, rowCount(dateParent))) + return false; + } + } + return true; +} + +void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) +{ + if (sourceModel()) { + disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); + disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); + disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + } + + QAbstractProxyModel::setSourceModel(newSourceModel); + + if (newSourceModel) { + connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); + connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); + connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + } + + reset(); +} + +void HistoryTreeModel::sourceReset() +{ + m_sourceRowCache.clear(); + reset(); +} + +void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, int end) +{ + Q_UNUSED(parent); // Avoid warnings when compiling release + Q_ASSERT(!parent.isValid()); + if (start != 0 || start != end) { + m_sourceRowCache.clear(); + reset(); + return; + } + + m_sourceRowCache.clear(); + QModelIndex treeIndex = mapFromSource(sourceModel()->index(start, 0)); + QModelIndex treeParent = treeIndex.parent(); + if (rowCount(treeParent) == 1) { + beginInsertRows(QModelIndex(), 0, 0); + endInsertRows(); + } else { + beginInsertRows(treeParent, treeIndex.row(), treeIndex.row()); + endInsertRows(); + } +} + +QModelIndex HistoryTreeModel::mapFromSource(const QModelIndex &sourceIndex) const +{ + if (!sourceIndex.isValid()) + return QModelIndex(); + + if (m_sourceRowCache.isEmpty()) + rowCount(QModelIndex()); + + QList::iterator it; + it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), sourceIndex.row()); + if (*it != sourceIndex.row()) + --it; + int dateRow = qMax(0, it - m_sourceRowCache.begin()); + int row = sourceIndex.row() - m_sourceRowCache.at(dateRow); + return createIndex(row, sourceIndex.column(), dateRow + 1); +} + +void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, int end) +{ + Q_UNUSED(parent); // Avoid warnings when compiling release + Q_ASSERT(!parent.isValid()); + if (m_sourceRowCache.isEmpty()) + return; + for (int i = end; i >= start;) { + QList::iterator it; + it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i); + // playing it safe + if (it == m_sourceRowCache.end()) { + m_sourceRowCache.clear(); + reset(); + return; + } + + if (*it != i) + --it; + int row = qMax(0, it - m_sourceRowCache.begin()); + int offset = m_sourceRowCache[row]; + QModelIndex dateParent = index(row, 0); + // If we can remove all the rows in the date do that and skip over them + int rc = rowCount(dateParent); + if (i - rc + 1 == offset && start <= i - rc + 1) { + beginRemoveRows(QModelIndex(), row, row); + m_sourceRowCache.removeAt(row); + i -= rc + 1; + } else { + beginRemoveRows(dateParent, i - offset, i - offset); + ++row; + --i; + } + for (int j = row; j < m_sourceRowCache.count(); ++j) + --m_sourceRowCache[j]; + endRemoveRows(); + } +} diff --git a/src/history.h b/src/history.h new file mode 100644 index 00000000..cda78a5a --- /dev/null +++ b/src/history.h @@ -0,0 +1,346 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef HISTORY_H +#define HISTORY_H + +#include "modelmenu.h" + +#include +#include +#include +#include +#include + +#include + +#include + +class HistoryItem +{ +public: + HistoryItem() {} + HistoryItem(const QString &u, + const QDateTime &d = QDateTime(), const QString &t = QString()) + : title(t), url(u), dateTime(d) {} + + inline bool operator==(const HistoryItem &other) const + { return other.title == title + && other.url == url && other.dateTime == dateTime; } + + // history is sorted in reverse + inline bool operator <(const HistoryItem &other) const + { return dateTime > other.dateTime; } + + QString title; + QString url; + QDateTime dateTime; +}; + +class AutoSaver; +class HistoryModel; +class HistoryFilterModel; +class HistoryTreeModel; +class HistoryManager : public QWebHistoryInterface +{ + Q_OBJECT + Q_PROPERTY(int historyLimit READ historyLimit WRITE setHistoryLimit) + +signals: + void historyReset(); + void entryAdded(const HistoryItem &item); + void entryRemoved(const HistoryItem &item); + void entryUpdated(int offset); + +public: + HistoryManager(QObject *parent = 0); + ~HistoryManager(); + + bool historyContains(const QString &url) const; + void addHistoryEntry(const QString &url); + + void updateHistoryItem(const QUrl &url, const QString &title); + + int historyLimit() const; + void setHistoryLimit(int limit); + + QList history() const; + void setHistory(const QList &history, bool loadedAndSorted = false); + + // History manager keeps around these models for use by the completer and other classes + HistoryModel *historyModel() const; + HistoryFilterModel *historyFilterModel() const; + HistoryTreeModel *historyTreeModel() const; + +public slots: + void clear(); + void loadSettings(); + +private slots: + void save(); + void checkForExpired(); + +protected: + void addHistoryItem(const HistoryItem &item); + +private: + void load(); + + AutoSaver *m_saveTimer; + int m_historyLimit; + QTimer m_expiredTimer; + QList m_history; + QString m_lastSavedUrl; + + HistoryModel *m_historyModel; + HistoryFilterModel *m_historyFilterModel; + HistoryTreeModel *m_historyTreeModel; +}; + +class HistoryModel : public QAbstractTableModel +{ + Q_OBJECT + +public slots: + void historyReset(); + void entryAdded(); + void entryUpdated(int offset); + +public: + enum Roles { + DateRole = Qt::UserRole + 1, + DateTimeRole = Qt::UserRole + 2, + UrlRole = Qt::UserRole + 3, + UrlStringRole = Qt::UserRole + 4 + }; + + HistoryModel(HistoryManager *history, QObject *parent = 0); + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + +private: + HistoryManager *m_history; +}; + +/*! + Proxy model that will remove any duplicate entries. + Both m_sourceRow and m_historyHash store their offsets not from + the front of the list, but as offsets from the back. + */ +class HistoryFilterModel : public QAbstractProxyModel +{ + Q_OBJECT + +public: + HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent = 0); + + inline bool historyContains(const QString &url) const + { load(); return m_historyHash.contains(url); } + int historyLocation(const QString &url) const; + + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; + QModelIndex mapToSource(const QModelIndex &proxyIndex) const; + void setSourceModel(QAbstractItemModel *sourceModel); + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; + QModelIndex parent(const QModelIndex& index= QModelIndex()) const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + +private slots: + void sourceReset(); + void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void sourceRowsInserted(const QModelIndex &parent, int start, int end); + void sourceRowsRemoved(const QModelIndex &, int, int); + +private: + void load() const; + + mutable QList m_sourceRow; + mutable QHash m_historyHash; + mutable bool m_loaded; +}; + +/* + The history menu + - Removes the first twenty entries and puts them as children of the top level. + - If there are less then twenty entries then the first folder is also removed. + + The mapping is done by knowing that HistoryTreeModel is over a table + We store that row offset in our index's private data. +*/ +class HistoryMenuModel : public QAbstractProxyModel +{ + Q_OBJECT + +public: + HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent = 0); + int columnCount(const QModelIndex &parent) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QModelIndex mapFromSource(const QModelIndex & sourceIndex) const; + QModelIndex mapToSource(const QModelIndex & proxyIndex) const; + QModelIndex index(int, int, const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index = QModelIndex()) const; + + int bumpedRows() const; + +private: + HistoryTreeModel *m_treeModel; +}; + +// Menu that is dynamically populated from the history +class HistoryMenu : public ModelMenu +{ + Q_OBJECT + +signals: + void openUrl(const QUrl &url); + +public: + HistoryMenu(QWidget *parent = 0); + void setInitialActions(QList actions); + +protected: + bool prePopulated(); + void postPopulated(); + +private slots: + void activated(const QModelIndex &index); + void showHistoryDialog(); + +private: + HistoryManager *m_history; + HistoryMenuModel *m_historyMenuModel; + QList m_initialActions; +}; + +// proxy model for the history model that +// exposes each url http://www.foo.com and it url starting at the host www.foo.com +class HistoryCompletionModel : public QAbstractProxyModel +{ + Q_OBJECT + +public: + HistoryCompletionModel(QObject *parent = 0); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; + QModelIndex mapToSource(const QModelIndex &proxyIndex) const; + QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; + QModelIndex parent(const QModelIndex& index= QModelIndex()) const; + void setSourceModel(QAbstractItemModel *sourceModel); + +private slots: + void sourceReset(); + +}; + +// proxy model for the history model that converts the list +// into a tree, one top level node per day. +// Used in the HistoryDialog. +class HistoryTreeModel : public QAbstractProxyModel +{ + Q_OBJECT + +public: + HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent = 0); + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int columnCount(const QModelIndex &parent) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; + QModelIndex mapToSource(const QModelIndex &proxyIndex) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index= QModelIndex()) const; + bool hasChildren(const QModelIndex &parent = QModelIndex()) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + + void setSourceModel(QAbstractItemModel *sourceModel); + +private slots: + void sourceReset(); + void sourceRowsInserted(const QModelIndex &parent, int start, int end); + void sourceRowsRemoved(const QModelIndex &parent, int start, int end); + +private: + int sourceDateRow(int row) const; + mutable QList m_sourceRowCache; + +}; + +// A modified QSortFilterProxyModel that always accepts the root nodes in the tree +// so filtering is only done on the children. +// Used in the HistoryDialog +class TreeProxyModel : public QSortFilterProxyModel +{ + Q_OBJECT + +public: + TreeProxyModel(QObject *parent = 0); + +protected: + bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; +}; + +#include "ui_history.h" + +class HistoryDialog : public QDialog, public Ui_HistoryDialog +{ + Q_OBJECT + +signals: + void openUrl(const QUrl &url); + +public: + HistoryDialog(QWidget *parent = 0, HistoryManager *history = 0); + +private slots: + void customContextMenuRequested(const QPoint &pos); + void open(); + void copy(); + +}; + +#endif // HISTORY_H + diff --git a/src/history.ui b/src/history.ui new file mode 100644 index 00000000..0944940e --- /dev/null +++ b/src/history.ui @@ -0,0 +1,106 @@ + + HistoryDialog + + + + 0 + 0 + 758 + 450 + + + + History + + + + + + Qt::Horizontal + + + + 252 + 20 + + + + + + + + + + + + + + + + &Remove + + + + + + + Remove &All + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QDialogButtonBox::Ok + + + + + + + + + + SearchLineEdit + QLineEdit +
searchlineedit.h
+
+ + EditTreeView + QTreeView +
edittreeview.h
+
+
+ + + + buttonBox + accepted() + HistoryDialog + accept() + + + 472 + 329 + + + 461 + 356 + + + + +
diff --git a/src/htmls/htmls.qrc b/src/htmls/htmls.qrc new file mode 100644 index 00000000..03b256cc --- /dev/null +++ b/src/htmls/htmls.qrc @@ -0,0 +1,5 @@ + + + notfound.html + + diff --git a/src/htmls/notfound.html b/src/htmls/notfound.html new file mode 100755 index 00000000..b428a6a3 --- /dev/null +++ b/src/htmls/notfound.html @@ -0,0 +1,63 @@ + + +%1 + + + +
+ +

%2

+

When connecting to: %3.

+
    +
  • Check the address for errors such as ww.trolltech.com + instead of www.trolltech.com
  • +
  • If the address is correct, try to check the network + connection.
  • +
  • If your computer or network is protected by a firewall or + proxy, make sure that the browser demo is permitted to access + the network.
  • +
+

+
+ + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 00000000..ae4c2173 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,57 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +#include +#include + +#include "browserapplication.h" + +int main(int argc, char **argv) +{ + KAboutData aboutData( + "reKonq", + 0, + ki18n("reKonq"), + "0.0.1", + ki18n("A KDE browser webkit based"), + KAboutData::License_GPL, + ki18n("Copyright (c) 2008 Andrea Diamantini"), + KLocalizedString(), + "http://www.adjam.org", + "adjam7@gmail.com" // bug report mail + ); + + aboutData.addAuthor(ki18n("Andrea Diamantini"), ki18n("reKonq author"), "adjam7@gmail.com"); + aboutData.setProgramIconName("application-internet"); + + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineOptions options; + + //TODO make this work + options.add("+URL", ki18n("Location to open")); + KCmdLineArgs::addCmdLineOptions( options ); + + BrowserApplication app(argc, argv); + if (!app.isTheOnlyBrowser()) + return 0; + app.newMainWindow(); + return app.exec(); +} + diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp new file mode 100644 index 00000000..3a8fb0cd --- /dev/null +++ b/src/modelmenu.cpp @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "modelmenu.h" + +#include +#include + +ModelMenu::ModelMenu(QWidget * parent) + : QMenu(parent) + , m_maxRows(7) + , m_firstSeparator(-1) + , m_maxWidth(-1) + , m_hoverRole(0) + , m_separatorRole(0) + , m_model(0) +{ + connect(this, SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); +} + +bool ModelMenu::prePopulated() +{ + return false; +} + +void ModelMenu::postPopulated() +{ +} + +void ModelMenu::setModel(QAbstractItemModel *model) +{ + m_model = model; +} + +QAbstractItemModel *ModelMenu::model() const +{ + return m_model; +} + +void ModelMenu::setMaxRows(int max) +{ + m_maxRows = max; +} + +int ModelMenu::maxRows() const +{ + return m_maxRows; +} + +void ModelMenu::setFirstSeparator(int offset) +{ + m_firstSeparator = offset; +} + +int ModelMenu::firstSeparator() const +{ + return m_firstSeparator; +} + +void ModelMenu::setRootIndex(const QModelIndex &index) +{ + m_root = index; +} + +QModelIndex ModelMenu::rootIndex() const +{ + return m_root; +} + +void ModelMenu::setHoverRole(int role) +{ + m_hoverRole = role; +} + +int ModelMenu::hoverRole() const +{ + return m_hoverRole; +} + +void ModelMenu::setSeparatorRole(int role) +{ + m_separatorRole = role; +} + +int ModelMenu::separatorRole() const +{ + return m_separatorRole; +} + +Q_DECLARE_METATYPE(QModelIndex) +void ModelMenu::aboutToShow() +{ + if (QMenu *menu = qobject_cast(sender())) { + QVariant v = menu->menuAction()->data(); + if (v.canConvert()) { + QModelIndex idx = qvariant_cast(v); + createMenu(idx, -1, menu, menu); + disconnect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); + return; + } + } + + clear(); + if (prePopulated()) + addSeparator(); + int max = m_maxRows; + if (max != -1) + max += m_firstSeparator; + createMenu(m_root, max, this, this); + postPopulated(); +} + +void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu, QMenu *menu) +{ + if (!menu) { + QString title = parent.data().toString(); + menu = new QMenu(title, this); + QIcon icon = qvariant_cast(parent.data(Qt::DecorationRole)); + menu->setIcon(icon); + parentMenu->addMenu(menu); + QVariant v; + v.setValue(parent); + menu->menuAction()->setData(v); + connect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); + return; + } + + int end = m_model->rowCount(parent); + if (max != -1) + end = qMin(max, end); + + connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*))); + connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(hovered(QAction*))); + + for (int i = 0; i < end; ++i) { + QModelIndex idx = m_model->index(i, 0, parent); + if (m_model->hasChildren(idx)) { + createMenu(idx, -1, menu); + } else { + if (m_separatorRole != 0 + && idx.data(m_separatorRole).toBool()) + addSeparator(); + else + menu->addAction(makeAction(idx)); + } + if (menu == this && i == m_firstSeparator - 1) + addSeparator(); + } +} + +QAction *ModelMenu::makeAction(const QModelIndex &index) +{ + QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); + QAction *action = makeAction(icon, index.data().toString(), this); + QVariant v; + v.setValue(index); + action->setData(v); + return action; +} + +QAction *ModelMenu::makeAction(const QIcon &icon, const QString &text, QObject *parent) +{ + QFontMetrics fm(font()); + if (-1 == m_maxWidth) + m_maxWidth = fm.width(QLatin1Char('m')) * 30; + QString smallText = fm.elidedText(text, Qt::ElideMiddle, m_maxWidth); + return new QAction(icon, smallText, parent); +} + +void ModelMenu::triggered(QAction *action) +{ + QVariant v = action->data(); + if (v.canConvert()) { + QModelIndex idx = qvariant_cast(v); + emit activated(idx); + } +} + +void ModelMenu::hovered(QAction *action) +{ + QVariant v = action->data(); + if (v.canConvert()) { + QModelIndex idx = qvariant_cast(v); + QString hoveredString = idx.data(m_hoverRole).toString(); + if (!hoveredString.isEmpty()) + emit hovered(hoveredString); + } +} diff --git a/src/modelmenu.h b/src/modelmenu.h new file mode 100644 index 00000000..81928256 --- /dev/null +++ b/src/modelmenu.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef MODELMENU_H +#define MODELMENU_H + +#include +#include + +// A QMenu that is dynamically populated from a QAbstractItemModel +class ModelMenu : public QMenu +{ + Q_OBJECT + +signals: + void activated(const QModelIndex &index); + void hovered(const QString &text); + +public: + ModelMenu(QWidget *parent = 0); + + void setModel(QAbstractItemModel *model); + QAbstractItemModel *model() const; + + void setMaxRows(int max); + int maxRows() const; + + void setFirstSeparator(int offset); + int firstSeparator() const; + + void setRootIndex(const QModelIndex &index); + QModelIndex rootIndex() const; + + void setHoverRole(int role); + int hoverRole() const; + + void setSeparatorRole(int role); + int separatorRole() const; + + QAction *makeAction(const QIcon &icon, const QString &text, QObject *parent); + +protected: + // add any actions before the tree, return true if any actions are added. + virtual bool prePopulated(); + // add any actions after the tree + virtual void postPopulated(); + // put all of the children of parent into menu up to max + void createMenu(const QModelIndex &parent, int max, QMenu *parentMenu = 0, QMenu *menu = 0); + +private slots: + void aboutToShow(); + void triggered(QAction *action); + void hovered(QAction *action); + +private: + QAction *makeAction(const QModelIndex &index); + int m_maxRows; + int m_firstSeparator; + int m_maxWidth; + int m_hoverRole; + int m_separatorRole; + QAbstractItemModel *m_model; + QPersistentModelIndex m_root; +}; + +#endif // MODELMENU_H + diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp new file mode 100644 index 00000000..8922c8c0 --- /dev/null +++ b/src/networkaccessmanager.cpp @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "networkaccessmanager.h" + +#include "browserapplication.h" +#include "browsermainwindow.h" +#include "ui_passworddialog.h" +#include "ui_proxy.h" + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +NetworkAccessManager::NetworkAccessManager(QObject *parent) + : QNetworkAccessManager(parent) +{ + connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), + SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); + connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), + SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); +#ifndef QT_NO_OPENSSL + connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList&)), + SLOT(sslErrors(QNetworkReply*, const QList&))); +#endif + loadSettings(); +} + +void NetworkAccessManager::loadSettings() +{ + QSettings settings; + settings.beginGroup(QLatin1String("proxy")); + QNetworkProxy proxy; + if (settings.value(QLatin1String("enabled"), false).toBool()) { + if (settings.value(QLatin1String("type"), 0).toInt() == 0) + proxy.setType(QNetworkProxy::Socks5Proxy); + else + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName(settings.value(QLatin1String("hostName")).toString()); + proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt()); + proxy.setUser(settings.value(QLatin1String("userName")).toString()); + proxy.setPassword(settings.value(QLatin1String("password")).toString()); + } + setProxy(proxy); +} + +void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) +{ + BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + + QDialog dialog(mainWindow); + dialog.setWindowFlags(Qt::Sheet); + + Ui::PasswordDialog passwordDialog; + passwordDialog.setupUi(&dialog); + + passwordDialog.iconLabel->setText(QString()); + passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); + + QString introMessage = tr("Enter username and password for \"%1\" at %2"); + introMessage = introMessage.arg(Qt::escape(reply->url().toString())).arg(Qt::escape(reply->url().toString())); + passwordDialog.introLabel->setText(introMessage); + passwordDialog.introLabel->setWordWrap(true); + + if (dialog.exec() == QDialog::Accepted) { + auth->setUser(passwordDialog.userNameLineEdit->text()); + auth->setPassword(passwordDialog.passwordLineEdit->text()); + } +} + +void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth) +{ + BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + + QDialog dialog(mainWindow); + dialog.setWindowFlags(Qt::Sheet); + + Ui::ProxyDialog proxyDialog; + proxyDialog.setupUi(&dialog); + + proxyDialog.iconLabel->setText(QString()); + proxyDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); + + QString introMessage = tr("Connect to proxy \"%1\" using:"); + introMessage = introMessage.arg(Qt::escape(proxy.hostName())); + proxyDialog.introLabel->setText(introMessage); + proxyDialog.introLabel->setWordWrap(true); + + if (dialog.exec() == QDialog::Accepted) { + auth->setUser(proxyDialog.userNameLineEdit->text()); + auth->setPassword(proxyDialog.passwordLineEdit->text()); + } +} + +#ifndef QT_NO_OPENSSL +void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList &error) +{ + BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + + QStringList errorStrings; + for (int i = 0; i < error.count(); ++i) + errorStrings += error.at(i).errorString(); + QString errors = errorStrings.join(QLatin1String("\n")); + int ret = QMessageBox::warning(mainWindow, QCoreApplication::applicationName(), + tr("SSL Errors:\n\n%1\n\n%2\n\n" + "Do you want to ignore these errors?").arg(reply->url().toString()).arg(errors), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No); + if (ret == QMessageBox::Yes) + reply->ignoreSslErrors(); +} +#endif diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h new file mode 100644 index 00000000..d49c7fa4 --- /dev/null +++ b/src/networkaccessmanager.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef NETWORKACCESSMANAGER_H +#define NETWORKACCESSMANAGER_H + +#include + +class NetworkAccessManager : public QNetworkAccessManager +{ + Q_OBJECT + +public: + NetworkAccessManager(QObject *parent = 0); + +public slots: + void loadSettings(); + +private slots: + void authenticationRequired(QNetworkReply *reply, QAuthenticator *auth); + void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth); +#ifndef QT_NO_OPENSSL + void sslErrors(QNetworkReply *reply, const QList &error); +#endif +}; + +#endif // NETWORKACCESSMANAGER_H diff --git a/src/passworddialog.ui b/src/passworddialog.ui new file mode 100644 index 00000000..7c166586 --- /dev/null +++ b/src/passworddialog.ui @@ -0,0 +1,111 @@ + + PasswordDialog + + + + 0 + 0 + 399 + 148 + + + + Authentication Required + + + + + + + + DUMMY ICON + + + + + + + + 0 + 0 + + + + INTRO TEXT DUMMY + + + + + + + + + Username: + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + PasswordDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + PasswordDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/proxy.ui b/src/proxy.ui new file mode 100644 index 00000000..62a8be62 --- /dev/null +++ b/src/proxy.ui @@ -0,0 +1,104 @@ + + ProxyDialog + + + + 0 + 0 + 369 + 144 + + + + Proxy Authentication + + + + + + ICON + + + + + + + Connect to proxy + + + true + + + + + + + Username: + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ProxyDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ProxyDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/searchlineedit.cpp b/src/searchlineedit.cpp new file mode 100644 index 00000000..97fdf726 --- /dev/null +++ b/src/searchlineedit.cpp @@ -0,0 +1,233 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "searchlineedit.h" + +#include +#include +#include +#include +#include + +ClearButton::ClearButton(QWidget *parent) + : QAbstractButton(parent) +{ + setCursor(Qt::ArrowCursor); + setToolTip(tr("Clear")); + setVisible(false); + setFocusPolicy(Qt::NoFocus); +} + +void ClearButton::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainter painter(this); + int height = this->height(); + + painter.setRenderHint(QPainter::Antialiasing, true); + QColor color = palette().color(QPalette::Mid); + painter.setBrush(isDown() + ? palette().color(QPalette::Dark) + : palette().color(QPalette::Mid)); + painter.setPen(painter.brush().color()); + int size = width(); + int offset = size / 5; + int radius = size - offset * 2; + painter.drawEllipse(offset, offset, radius, radius); + + painter.setPen(palette().color(QPalette::Base)); + int border = offset * 2; + painter.drawLine(border, border, width() - border, height - border); + painter.drawLine(border, height - border, width() - border, border); +} + +void ClearButton::textChanged(const QString &text) +{ + setVisible(!text.isEmpty()); +} + +/* + Search icon on the left hand side of the search widget + When a menu is set a down arrow appears + */ +class SearchButton : public QAbstractButton { +public: + SearchButton(QWidget *parent = 0); + void paintEvent(QPaintEvent *event); + QMenu *m_menu; + +protected: + void mousePressEvent(QMouseEvent *event); +}; + +SearchButton::SearchButton(QWidget *parent) + : QAbstractButton(parent), + m_menu(0) +{ + setObjectName(QLatin1String("SearchButton")); + setCursor(Qt::ArrowCursor); + setFocusPolicy(Qt::NoFocus); +} + +void SearchButton::mousePressEvent(QMouseEvent *event) +{ + if (m_menu && event->button() == Qt::LeftButton) { + QWidget *p = parentWidget(); + if (p) { + QPoint r = p->mapToGlobal(QPoint(0, p->height())); + m_menu->exec(QPoint(r.x() + height() / 2, r.y())); + } + event->accept(); + } + QAbstractButton::mousePressEvent(event); +} + +void SearchButton::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + QPainterPath myPath; + + int radius = (height() / 5) * 2; + QRect circle(height() / 3 - 1, height() / 4, radius, radius); + myPath.addEllipse(circle); + + myPath.arcMoveTo(circle, 300); + QPointF c = myPath.currentPosition(); + int diff = height() / 7; + myPath.lineTo(qMin(width() - 2, (int)c.x() + diff), c.y() + diff); + + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::darkGray, 2)); + painter.drawPath(myPath); + + if (m_menu) { + QPainterPath dropPath; + dropPath.arcMoveTo(circle, 320); + QPointF c = dropPath.currentPosition(); + c = QPointF(c.x() + 3.5, c.y() + 0.5); + dropPath.moveTo(c); + dropPath.lineTo(c.x() + 4, c.y()); + dropPath.lineTo(c.x() + 2, c.y() + 2); + dropPath.closeSubpath(); + painter.setPen(Qt::darkGray); + painter.setBrush(Qt::darkGray); + painter.setRenderHint(QPainter::Antialiasing, false); + painter.drawPath(dropPath); + } + painter.end(); +} + +/* + SearchLineEdit is an enhanced QLineEdit + - A Search icon on the left with optional menu + - When there is no text and doesn't have focus an "inactive text" is displayed + - When there is text a clear button is displayed on the right hand side + */ +SearchLineEdit::SearchLineEdit(QWidget *parent) : ExLineEdit(parent), + m_searchButton(new SearchButton(this)) +{ + connect(lineEdit(), SIGNAL(textChanged(const QString &)), + this, SIGNAL(textChanged(const QString &))); + setLeftWidget(m_searchButton); + m_inactiveText = tr("Search"); + + QSizePolicy policy = sizePolicy(); + setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); +} + +void SearchLineEdit::paintEvent(QPaintEvent *event) +{ + if (lineEdit()->text().isEmpty() && !hasFocus() && !m_inactiveText.isEmpty()) { + ExLineEdit::paintEvent(event); + QStyleOptionFrameV2 panel; + initStyleOption(&panel); + QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); + QFontMetrics fm = fontMetrics(); + int horizontalMargin = lineEdit()->x(); + QRect lineRect(horizontalMargin + r.x(), r.y() + (r.height() - fm.height() + 1) / 2, + r.width() - 2 * horizontalMargin, fm.height()); + QPainter painter(this); + painter.setPen(palette().brush(QPalette::Disabled, QPalette::Text).color()); + painter.drawText(lineRect, Qt::AlignLeft|Qt::AlignVCenter, m_inactiveText); + } else { + ExLineEdit::paintEvent(event); + } +} + +void SearchLineEdit::resizeEvent(QResizeEvent *event) +{ + updateGeometries(); + ExLineEdit::resizeEvent(event); +} + +void SearchLineEdit::updateGeometries() +{ + int menuHeight = height(); + int menuWidth = menuHeight + 1; + if (!m_searchButton->m_menu) + menuWidth = (menuHeight / 5) * 4; + m_searchButton->resize(QSize(menuWidth, menuHeight)); +} + +QString SearchLineEdit::inactiveText() const +{ + return m_inactiveText; +} + +void SearchLineEdit::setInactiveText(const QString &text) +{ + m_inactiveText = text; +} + +void SearchLineEdit::setMenu(QMenu *menu) +{ + if (m_searchButton->m_menu) + m_searchButton->m_menu->deleteLater(); + m_searchButton->m_menu = menu; + updateGeometries(); +} + +QMenu *SearchLineEdit::menu() const +{ + if (!m_searchButton->m_menu) { + m_searchButton->m_menu = new QMenu(m_searchButton); + if (isVisible()) + (const_cast(this))->updateGeometries(); + } + return m_searchButton->m_menu; +} diff --git a/src/searchlineedit.h b/src/searchlineedit.h new file mode 100644 index 00000000..2f2a8362 --- /dev/null +++ b/src/searchlineedit.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef SEARCHLINEEDIT_H +#define SEARCHLINEEDIT_H + +#include "urllineedit.h" + +#include +#include + +QT_BEGIN_NAMESPACE +class QMenu; +QT_END_NAMESPACE + +class SearchButton; + +/* + Clear button on the right hand side of the search widget. + Hidden by default + "A circle with an X in it" + */ +class ClearButton : public QAbstractButton +{ + Q_OBJECT + +public: + ClearButton(QWidget *parent = 0); + void paintEvent(QPaintEvent *event); + +public slots: + void textChanged(const QString &text); +}; + + +class SearchLineEdit : public ExLineEdit +{ + Q_OBJECT + Q_PROPERTY(QString inactiveText READ inactiveText WRITE setInactiveText) + +signals: + void textChanged(const QString &text); + +public: + SearchLineEdit(QWidget *parent = 0); + + QString inactiveText() const; + void setInactiveText(const QString &text); + + QMenu *menu() const; + void setMenu(QMenu *menu); + +protected: + void resizeEvent(QResizeEvent *event); + void paintEvent(QPaintEvent *event); + +private: + void updateGeometries(); + + SearchButton *m_searchButton; + QString m_inactiveText; +}; + +#endif // SEARCHLINEEDIT_H + diff --git a/src/settings.cpp b/src/settings.cpp new file mode 100644 index 00000000..a3a85ee1 --- /dev/null +++ b/src/settings.cpp @@ -0,0 +1,320 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "settings.h" + +#include "browserapplication.h" +#include "browsermainwindow.h" +#include "cookiejar.h" +#include "history.h" +#include "networkaccessmanager.h" +#include "webview.h" + +#include +#include +#include + +SettingsDialog::SettingsDialog(QWidget *parent) + : QDialog(parent) +{ + setupUi(this); + connect(exceptionsButton, SIGNAL(clicked()), this, SLOT(showExceptions())); + connect(setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); + connect(cookiesButton, SIGNAL(clicked()), this, SLOT(showCookies())); + connect(standardFontButton, SIGNAL(clicked()), this, SLOT(chooseFont())); + connect(fixedFontButton, SIGNAL(clicked()), this, SLOT(chooseFixedFont())); + + loadDefaults(); + loadFromSettings(); +} + +void SettingsDialog::loadDefaults() +{ + QWebSettings *defaultSettings = QWebSettings::globalSettings(); + QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); + int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); + standardFont = QFont(standardFontFamily, standardFontSize); + standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); + + QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); + int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); + fixedFont = QFont(fixedFontFamily, fixedFontSize); + fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); + + downloadsLocation->setText(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); + + enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); + enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); +} + +void SettingsDialog::loadFromSettings() +{ + QSettings settings; + settings.beginGroup(QLatin1String("MainWindow")); + QString defaultHome = QLatin1String("http://www.trolltech.com"); + homeLineEdit->setText(settings.value(QLatin1String("home"), defaultHome).toString()); + settings.endGroup(); + + settings.beginGroup(QLatin1String("history")); + int historyExpire = settings.value(QLatin1String("historyExpire")).toInt(); + int idx = 0; + switch (historyExpire) { + case 1: idx = 0; break; + case 7: idx = 1; break; + case 14: idx = 2; break; + case 30: idx = 3; break; + case 365: idx = 4; break; + case -1: idx = 5; break; + default: + idx = 5; + } + expireHistory->setCurrentIndex(idx); + settings.endGroup(); + + settings.beginGroup(QLatin1String("downloadmanager")); + QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), downloadsLocation->text()).toString(); + downloadsLocation->setText(downloadDirectory); + settings.endGroup(); + + settings.beginGroup(QLatin1String("general")); + openLinksIn->setCurrentIndex(settings.value(QLatin1String("openLinksIn"), openLinksIn->currentIndex()).toInt()); + + settings.endGroup(); + + // Appearance + settings.beginGroup(QLatin1String("websettings")); + fixedFont = qVariantValue(settings.value(QLatin1String("fixedFont"), fixedFont)); + standardFont = qVariantValue(settings.value(QLatin1String("standardFont"), standardFont)); + + standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); + fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); + + enableJavascript->setChecked(settings.value(QLatin1String("enableJavascript"), enableJavascript->isChecked()).toBool()); + enablePlugins->setChecked(settings.value(QLatin1String("enablePlugins"), enablePlugins->isChecked()).toBool()); + userStyleSheet->setText(settings.value(QLatin1String("userStyleSheet")).toUrl().toString()); + settings.endGroup(); + + // Privacy + settings.beginGroup(QLatin1String("cookies")); + + CookieJar *jar = BrowserApplication::cookieJar(); + QByteArray value = settings.value(QLatin1String("acceptCookies"), QLatin1String("AcceptOnlyFromSitesNavigatedTo")).toByteArray(); + QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); + CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue(value) == -1 ? + CookieJar::AcceptOnlyFromSitesNavigatedTo : + static_cast(acceptPolicyEnum.keyToValue(value)); + switch(acceptCookies) { + case CookieJar::AcceptAlways: + acceptCombo->setCurrentIndex(0); + break; + case CookieJar::AcceptNever: + acceptCombo->setCurrentIndex(1); + break; + case CookieJar::AcceptOnlyFromSitesNavigatedTo: + acceptCombo->setCurrentIndex(2); + break; + } + + value = settings.value(QLatin1String("keepCookiesUntil"), QLatin1String("Expire")).toByteArray(); + QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); + CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue(value) == -1 ? + CookieJar::KeepUntilExpire : + static_cast(keepPolicyEnum.keyToValue(value)); + switch(keepCookies) { + case CookieJar::KeepUntilExpire: + keepUntilCombo->setCurrentIndex(0); + break; + case CookieJar::KeepUntilExit: + keepUntilCombo->setCurrentIndex(1); + break; + case CookieJar::KeepUntilTimeLimit: + keepUntilCombo->setCurrentIndex(2); + break; + } + settings.endGroup(); + + + // Proxy + settings.beginGroup(QLatin1String("proxy")); + proxySupport->setChecked(settings.value(QLatin1String("enabled"), false).toBool()); + proxyType->setCurrentIndex(settings.value(QLatin1String("type"), 0).toInt()); + proxyHostName->setText(settings.value(QLatin1String("hostName")).toString()); + proxyPort->setValue(settings.value(QLatin1String("port"), 1080).toInt()); + proxyUserName->setText(settings.value(QLatin1String("userName")).toString()); + proxyPassword->setText(settings.value(QLatin1String("password")).toString()); + settings.endGroup(); +} + +void SettingsDialog::saveToSettings() +{ + QSettings settings; + settings.beginGroup(QLatin1String("MainWindow")); + settings.setValue(QLatin1String("home"), homeLineEdit->text()); + settings.endGroup(); + + settings.beginGroup(QLatin1String("general")); + settings.setValue(QLatin1String("openLinksIn"), openLinksIn->currentIndex()); + settings.endGroup(); + + settings.beginGroup(QLatin1String("history")); + int historyExpire = expireHistory->currentIndex(); + int idx = -1; + switch (historyExpire) { + case 0: idx = 1; break; + case 1: idx = 7; break; + case 2: idx = 14; break; + case 3: idx = 30; break; + case 4: idx = 365; break; + case 5: idx = -1; break; + } + settings.setValue(QLatin1String("historyExpire"), idx); + settings.endGroup(); + + // Appearance + settings.beginGroup(QLatin1String("websettings")); + settings.setValue(QLatin1String("fixedFont"), fixedFont); + settings.setValue(QLatin1String("standardFont"), standardFont); + settings.setValue(QLatin1String("enableJavascript"), enableJavascript->isChecked()); + settings.setValue(QLatin1String("enablePlugins"), enablePlugins->isChecked()); + QString userStyleSheetString = userStyleSheet->text(); + if (QFile::exists(userStyleSheetString)) + settings.setValue(QLatin1String("userStyleSheet"), QUrl::fromLocalFile(userStyleSheetString)); + else + settings.setValue(QLatin1String("userStyleSheet"), QUrl(userStyleSheetString)); + settings.endGroup(); + + //Privacy + settings.beginGroup(QLatin1String("cookies")); + + CookieJar::KeepPolicy keepCookies; + switch(acceptCombo->currentIndex()) { + default: + case 0: + keepCookies = CookieJar::KeepUntilExpire; + break; + case 1: + keepCookies = CookieJar::KeepUntilExit; + break; + case 2: + keepCookies = CookieJar::KeepUntilTimeLimit; + break; + } + CookieJar *jar = BrowserApplication::cookieJar(); + QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); + settings.setValue(QLatin1String("acceptCookies"), QLatin1String(acceptPolicyEnum.valueToKey(keepCookies))); + + CookieJar::KeepPolicy keepPolicy; + switch(keepUntilCombo->currentIndex()) { + default: + case 0: + keepPolicy = CookieJar::KeepUntilExpire; + break; + case 1: + keepPolicy = CookieJar::KeepUntilExit; + break; + case 2: + keepPolicy = CookieJar::KeepUntilTimeLimit; + break; + } + + QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); + settings.setValue(QLatin1String("keepCookiesUntil"), QLatin1String(keepPolicyEnum.valueToKey(keepPolicy))); + + settings.endGroup(); + + // proxy + settings.beginGroup(QLatin1String("proxy")); + settings.setValue(QLatin1String("enabled"), proxySupport->isChecked()); + settings.setValue(QLatin1String("type"), proxyType->currentIndex()); + settings.setValue(QLatin1String("hostName"), proxyHostName->text()); + settings.setValue(QLatin1String("port"), proxyPort->text()); + settings.setValue(QLatin1String("userName"), proxyUserName->text()); + settings.setValue(QLatin1String("password"), proxyPassword->text()); + settings.endGroup(); + + BrowserApplication::instance()->loadSettings(); + BrowserApplication::networkAccessManager()->loadSettings(); + BrowserApplication::cookieJar()->loadSettings(); + BrowserApplication::historyManager()->loadSettings(); +} + +void SettingsDialog::accept() +{ + saveToSettings(); + QDialog::accept(); +} + +void SettingsDialog::showCookies() +{ + CookiesDialog *dialog = new CookiesDialog(BrowserApplication::cookieJar(), this); + dialog->exec(); +} + +void SettingsDialog::showExceptions() +{ + CookiesExceptionsDialog *dialog = new CookiesExceptionsDialog(BrowserApplication::cookieJar(), this); + dialog->exec(); +} + +void SettingsDialog::chooseFont() +{ + bool ok; + QFont font = QFontDialog::getFont(&ok, standardFont, this); + if ( ok ) { + standardFont = font; + standardLabel->setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize())); + } +} + +void SettingsDialog::chooseFixedFont() +{ + bool ok; + QFont font = QFontDialog::getFont(&ok, fixedFont, this); + if ( ok ) { + fixedFont = font; + fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize())); + } +} + +void SettingsDialog::setHomeToCurrentPage() +{ + BrowserMainWindow *mw = static_cast(parent()); + WebView *webView = mw->currentTab(); + if (webView) + homeLineEdit->setText(webView->url().toString()); +} + diff --git a/src/settings.h b/src/settings.h new file mode 100644 index 00000000..dfd8dd15 --- /dev/null +++ b/src/settings.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef SETTINGS_H +#define SETTINGS_H + +#include +#include "ui_settings.h" + +class SettingsDialog : public QDialog, public Ui_Settings +{ + Q_OBJECT + +public: + SettingsDialog(QWidget *parent = 0); + void accept(); + +private slots: + void loadDefaults(); + void loadFromSettings(); + void saveToSettings(); + + void setHomeToCurrentPage(); + void showCookies(); + void showExceptions(); + + void chooseFont(); + void chooseFixedFont(); + +private: + QFont standardFont; + QFont fixedFont; +}; + +#endif // SETTINGS_H + diff --git a/src/settings.ui b/src/settings.ui new file mode 100644 index 00000000..3491ce0b --- /dev/null +++ b/src/settings.ui @@ -0,0 +1,614 @@ + + Settings + + + + 0 + 0 + 657 + 322 + + + + Settings + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + 0 + + + + + 0 + 0 + 627 + 243 + + + + General + + + + + + Home: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Set to current page + + + + + + + Qt::Horizontal + + + + 280 + 18 + + + + + + + + Remove history items: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + After one day + + + + + After one week + + + + + After two weeks + + + + + After one month + + + + + After one year + + + + + Manually + + + + + + + + Save downloads to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Open links from applications: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + In a tab in the current window + + + + + In a new window + + + + + + + + Qt::Vertical + + + + 391 + 262 + + + + + + + + + + 0 + 0 + 627 + 243 + + + + Appearance + + + + + + Standard font: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + Times 16 + + + Qt::AlignCenter + + + + + + + Select... + + + + + + + Fixed-width font: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + QFrame::StyledPanel + + + Courier 13 + + + Qt::AlignCenter + + + + + + + Select... + + + + + + + Qt::Vertical + + + + 20 + 93 + + + + + + + + + + 0 + 0 + 627 + 243 + + + + Privacy + + + + + + Web Content + + + + + + Enable Plugins + + + true + + + + + + + Enable Javascript + + + true + + + + + + + + + + Cookies + + + + + + Accept Cookies: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Always + + + + + Never + + + + + Only from sites you navigate to + + + + + + + + Exceptions... + + + + + + + Keep until: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + They expire + + + + + I exit the application + + + + + At most 90 days + + + + + + + + Cookies... + + + + + + + + + + Qt::Vertical + + + + 371 + 177 + + + + + + + + + + 0 + 0 + 627 + 243 + + + + Proxy + + + + + + Enable proxy + + + true + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Socks5 + + + + + Http + + + + + + + + Host: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Port: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 10000 + + + 1080 + + + + + + + Qt::Horizontal + + + + 293 + 20 + + + + + + + + User Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Password: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + QLineEdit::Password + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + + Advanced + + + + + + Style Sheet: + + + + + + + + + + Qt::Vertical + + + + 20 + 176 + + + + + + + + + + + + + + buttonBox + accepted() + Settings + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Settings + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/squeezelabel.cpp b/src/squeezelabel.cpp new file mode 100644 index 00000000..f8687ca7 --- /dev/null +++ b/src/squeezelabel.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "squeezelabel.h" + +SqueezeLabel::SqueezeLabel(QWidget *parent) : QLabel(parent) +{ +} + +void SqueezeLabel::paintEvent(QPaintEvent *event) +{ + QFontMetrics fm = fontMetrics(); + if (fm.width(text()) > contentsRect().width()) { + QString elided = fm.elidedText(text(), Qt::ElideMiddle, width()); + QString oldText = text(); + setText(elided); + QLabel::paintEvent(event); + setText(oldText); + } else { + QLabel::paintEvent(event); + } +} diff --git a/src/squeezelabel.h b/src/squeezelabel.h new file mode 100644 index 00000000..8dd996ef --- /dev/null +++ b/src/squeezelabel.h @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef SQUEEZELABEL_H +#define SQUEEZELABEL_H + +#include + +class SqueezeLabel : public QLabel +{ + Q_OBJECT + +public: + SqueezeLabel(QWidget *parent = 0); + +protected: + void paintEvent(QPaintEvent *event); + +}; + +#endif // SQUEEZELABEL_H + diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp new file mode 100644 index 00000000..f873ec6f --- /dev/null +++ b/src/tabwidget.cpp @@ -0,0 +1,859 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "tabwidget.h" + +#include "browserapplication.h" +#include "browsermainwindow.h" +#include "history.h" +#include "urllineedit.h" +#include "webview.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +TabBar::TabBar(QWidget *parent) + : QTabBar(parent) +{ + setContextMenuPolicy(Qt::CustomContextMenu); + setAcceptDrops(true); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(contextMenuRequested(const QPoint &))); + + QString alt = QLatin1String("Alt+%1"); + for (int i = 1; i <= 10; ++i) { + int key = i; + if (key == 10) + key = 0; + QShortcut *shortCut = new QShortcut(alt.arg(key), this); + m_tabShortcuts.append(shortCut); + connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); + } +} + +void TabBar::selectTabAction() +{ + if (QShortcut *shortCut = qobject_cast(sender())) { + int index = m_tabShortcuts.indexOf(shortCut); + if (index == 0) + index = 10; + setCurrentIndex(index); + } +} + +void TabBar::contextMenuRequested(const QPoint &position) +{ + QMenu menu; + menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); + int index = tabAt(position); + if (-1 != index) { + QAction *action = menu.addAction(tr("Clone Tab"), + this, SLOT(cloneTab())); + action->setData(index); + + menu.addSeparator(); + + action = menu.addAction(tr("&Close Tab"), + this, SLOT(closeTab()), QKeySequence::Close); + action->setData(index); + + action = menu.addAction(tr("Close &Other Tabs"), + this, SLOT(closeOtherTabs())); + action->setData(index); + + menu.addSeparator(); + + action = menu.addAction(tr("Reload Tab"), + this, SLOT(reloadTab()), QKeySequence::Refresh); + action->setData(index); + } else { + menu.addSeparator(); + } + menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); + menu.exec(QCursor::pos()); +} + +void TabBar::cloneTab() +{ + if (QAction *action = qobject_cast(sender())) { + int index = action->data().toInt(); + emit cloneTab(index); + } +} + +void TabBar::closeTab() +{ + if (QAction *action = qobject_cast(sender())) { + int index = action->data().toInt(); + emit closeTab(index); + } +} + +void TabBar::closeOtherTabs() +{ + if (QAction *action = qobject_cast(sender())) { + int index = action->data().toInt(); + emit closeOtherTabs(index); + } +} + +void TabBar::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + m_dragStartPos = event->pos(); + QTabBar::mousePressEvent(event); +} + +void TabBar::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() == Qt::LeftButton + && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) { + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + QList urls; + int index = tabAt(event->pos()); + QUrl url = tabData(index).toUrl(); + urls.append(url); + mimeData->setUrls(urls); + mimeData->setText(tabText(index)); + mimeData->setData(QLatin1String("action"), "tab-reordering"); + drag->setMimeData(mimeData); + drag->exec(); + } + QTabBar::mouseMoveEvent(event); +} + +void TabBar::dragEnterEvent(QDragEnterEvent *event) +{ + const QMimeData *mimeData = event->mimeData(); + QStringList formats = mimeData->formats(); + if (formats.contains(QLatin1String("action")) + && (mimeData->data(QLatin1String("action")) == "tab-reordering")) { + event->acceptProposedAction(); + } + QTabBar::dragEnterEvent(event); +} + +void TabBar::dropEvent(QDropEvent *event) +{ + int fromIndex = tabAt(m_dragStartPos); + int toIndex = tabAt(event->pos()); + if (fromIndex != toIndex) { + emit tabMoveRequested(fromIndex, toIndex); + event->acceptProposedAction(); + } + QTabBar::dropEvent(event); +} + +// When index is -1 index chooses the current tab +void TabWidget::reloadTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + QWidget *widget = this->widget(index); + if (WebView *tab = qobject_cast(widget)) + tab->reload(); +} + +void TabBar::reloadTab() +{ + if (QAction *action = qobject_cast(sender())) { + int index = action->data().toInt(); + emit reloadTab(index); + } +} + +TabWidget::TabWidget(QWidget *parent) + : QTabWidget(parent) + , m_recentlyClosedTabsAction(0) + , m_newTabAction(0) + , m_closeTabAction(0) + , m_nextTabAction(0) + , m_previousTabAction(0) + , m_recentlyClosedTabsMenu(0) + , m_lineEditCompleter(0) + , m_lineEdits(0) + , m_tabBar(new TabBar(this)) +{ + setElideMode(Qt::ElideRight); + + connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); + connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); + connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); + connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); + connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); + connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); + connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); + setTabBar(m_tabBar); + + // Actions + m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this); + m_newTabAction->setShortcuts(QKeySequence::AddTab); + m_newTabAction->setIconVisibleInMenu(false); + connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); + + m_closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this); + m_closeTabAction->setShortcuts(QKeySequence::Close); + m_closeTabAction->setIconVisibleInMenu(false); + connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); + + m_nextTabAction = new QAction(tr("Show Next Tab"), this); + QList shortcuts; + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketRight)); + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Less)); + m_nextTabAction->setShortcuts(shortcuts); + connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); + + m_previousTabAction = new QAction(tr("Show Previous Tab"), this); + shortcuts.clear(); + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketLeft)); + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Greater)); + m_previousTabAction->setShortcuts(shortcuts); + connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); + + m_recentlyClosedTabsMenu = new QMenu(this); + connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), + this, SLOT(aboutToShowRecentTabsMenu())); + connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), + this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); + m_recentlyClosedTabsAction = new QAction(tr("Recently Closed Tabs"), this); + m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); + m_recentlyClosedTabsAction->setEnabled(false); + + // corner buttons + QToolButton *addTabButton = new QToolButton(this); + addTabButton->setDefaultAction(m_newTabAction); + addTabButton->setAutoRaise(true); + addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + setCornerWidget(addTabButton, Qt::TopLeftCorner); + + QToolButton *closeTabButton = new QToolButton(this); + closeTabButton->setDefaultAction(m_closeTabAction); + closeTabButton->setAutoRaise(true); + closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + setCornerWidget(closeTabButton, Qt::TopRightCorner); + + connect(this, SIGNAL(currentChanged(int)), + this, SLOT(currentChanged(int))); + + m_lineEdits = new QStackedWidget(this); +} + +void TabWidget::clear() +{ + // clear the recently closed tabs + m_recentlyClosedTabs.clear(); + // clear the line edit history + for (int i = 0; i < m_lineEdits->count(); ++i) { + QLineEdit *qLineEdit = lineEdit(i); + qLineEdit->setText(qLineEdit->text()); + } +} + +void TabWidget::moveTab(int fromIndex, int toIndex) +{ + disconnect(this, SIGNAL(currentChanged(int)), + this, SLOT(currentChanged(int))); + + QWidget *tabWidget = widget(fromIndex); + QIcon icon = tabIcon(fromIndex); + QString text = tabText(fromIndex); + QVariant data = m_tabBar->tabData(fromIndex); + removeTab(fromIndex); + insertTab(toIndex, tabWidget, icon, text); + m_tabBar->setTabData(toIndex, data); + connect(this, SIGNAL(currentChanged(int)), + this, SLOT(currentChanged(int))); + setCurrentIndex(toIndex); +} + +void TabWidget::addWebAction(QAction *action, QWebPage::WebAction webAction) +{ + if (!action) + return; + m_actions.append(new WebActionMapper(action, webAction, this)); +} + +void TabWidget::currentChanged(int index) +{ + WebView *webView = this->webView(index); + if (!webView) + return; + + Q_ASSERT(m_lineEdits->count() == count()); + + WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); + if (oldWebView) { + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), + this, SIGNAL(showStatusBarMessage(const QString&))); + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), + this, SIGNAL(linkHovered(const QString&))); + disconnect(oldWebView, SIGNAL(loadProgress(int)), + this, SIGNAL(loadProgress(int))); + } + + connect(webView, SIGNAL(statusBarMessage(const QString&)), + this, SIGNAL(showStatusBarMessage(const QString&))); + connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), + this, SIGNAL(linkHovered(const QString&))); + connect(webView, SIGNAL(loadProgress(int)), + this, SIGNAL(loadProgress(int))); + + for (int i = 0; i < m_actions.count(); ++i) { + WebActionMapper *mapper = m_actions[i]; + mapper->updateCurrent(webView->page()); + } + emit setCurrentTitle(webView->title()); + m_lineEdits->setCurrentIndex(index); + emit loadProgress(webView->progress()); + emit showStatusBarMessage(webView->lastStatusBarText()); + if (webView->url().isEmpty()) + m_lineEdits->currentWidget()->setFocus(); + else + webView->setFocus(); +} + +QAction *TabWidget::newTabAction() const +{ + return m_newTabAction; +} + +QAction *TabWidget::closeTabAction() const +{ + return m_closeTabAction; +} + +QAction *TabWidget::recentlyClosedTabsAction() const +{ + return m_recentlyClosedTabsAction; +} + +QAction *TabWidget::nextTabAction() const +{ + return m_nextTabAction; +} + +QAction *TabWidget::previousTabAction() const +{ + return m_previousTabAction; +} + +QWidget *TabWidget::lineEditStack() const +{ + return m_lineEdits; +} + +QLineEdit *TabWidget::currentLineEdit() const +{ + return lineEdit(m_lineEdits->currentIndex()); +} + +WebView *TabWidget::currentWebView() const +{ + return webView(currentIndex()); +} + +QLineEdit *TabWidget::lineEdit(int index) const +{ + UrlLineEdit *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); + if (urlLineEdit) + return urlLineEdit->lineEdit(); + return 0; +} + +WebView *TabWidget::webView(int index) const +{ + QWidget *widget = this->widget(index); + if (WebView *webView = qobject_cast(widget)) { + return webView; + } else { + // optimization to delay creating the first webview + if (count() == 1) { + TabWidget *that = const_cast(this); + that->setUpdatesEnabled(false); + that->newTab(); + that->closeTab(0); + that->setUpdatesEnabled(true); + return currentWebView(); + } + } + return 0; +} + +int TabWidget::webViewIndex(WebView *webView) const +{ + int index = indexOf(webView); + return index; +} + +WebView *TabWidget::newTab(bool makeCurrent) +{ + // line edit + UrlLineEdit *urlLineEdit = new UrlLineEdit; + QLineEdit *lineEdit = urlLineEdit->lineEdit(); + if (!m_lineEditCompleter && count() > 0) { + HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); + completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel()); + m_lineEditCompleter = new QCompleter(completionModel, this); + // Should this be in Qt by default? + QAbstractItemView *popup = m_lineEditCompleter->popup(); + QListView *listView = qobject_cast(popup); + if (listView) + listView->setUniformItemSizes(true); + } + lineEdit->setCompleter(m_lineEditCompleter); + connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed())); + m_lineEdits->addWidget(urlLineEdit); + m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); + + // optimization to delay creating the more expensive WebView, history, etc + if (count() == 0) { + QWidget *emptyWidget = new QWidget; + QPalette p = emptyWidget->palette(); + p.setColor(QPalette::Window, palette().color(QPalette::Base)); + emptyWidget->setPalette(p); + emptyWidget->setAutoFillBackground(true); + disconnect(this, SIGNAL(currentChanged(int)), + this, SLOT(currentChanged(int))); + addTab(emptyWidget, tr("(Untitled)")); + connect(this, SIGNAL(currentChanged(int)), + this, SLOT(currentChanged(int))); + return 0; + } + + // webview + WebView *webView = new WebView; + urlLineEdit->setWebView(webView); + connect(webView, SIGNAL(loadStarted()), + this, SLOT(webViewLoadStarted())); + connect(webView, SIGNAL(loadFinished(bool)), + this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged()), + this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(titleChanged(const QString &)), + this, SLOT(webViewTitleChanged(const QString &))); + connect(webView, SIGNAL(urlChanged(const QUrl &)), + this, SLOT(webViewUrlChanged(const QUrl &))); + connect(webView->page(), SIGNAL(windowCloseRequested()), + this, SLOT(windowCloseRequested())); + connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), + this, SIGNAL(geometryChangeRequested(const QRect &))); + connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), + this, SIGNAL(printRequested(QWebFrame *))); + connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), + this, SIGNAL(menuBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), + this, SIGNAL(statusBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), + this, SIGNAL(toolBarVisibilityChangeRequested(bool))); + addTab(webView, tr("(Untitled)")); + if (makeCurrent) + setCurrentWidget(webView); + + // webview actions + for (int i = 0; i < m_actions.count(); ++i) { + WebActionMapper *mapper = m_actions[i]; + mapper->addChild(webView->page()->action(mapper->webAction())); + } + + if (count() == 1) + currentChanged(currentIndex()); + emit tabsChanged(); + return webView; +} + +void TabWidget::reloadAllTabs() +{ + for (int i = 0; i < count(); ++i) { + QWidget *tabWidget = widget(i); + if (WebView *tab = qobject_cast(tabWidget)) { + tab->reload(); + } + } +} + +void TabWidget::lineEditReturnPressed() +{ + if (QLineEdit *lineEdit = qobject_cast(sender())) { + emit loadPage(lineEdit->text()); + if (m_lineEdits->currentWidget() == lineEdit) + currentWebView()->setFocus(); + } +} + +void TabWidget::windowCloseRequested() +{ + WebPage *webPage = qobject_cast(sender()); + WebView *webView = qobject_cast(webPage->view()); + int index = webViewIndex(webView); + if (index >= 0) { + if (count() == 1) + webView->webPage()->mainWindow()->close(); + else + closeTab(index); + } +} + +void TabWidget::closeOtherTabs(int index) +{ + if (-1 == index) + return; + for (int i = count() - 1; i > index; --i) + closeTab(i); + for (int i = index - 1; i >= 0; --i) + closeTab(i); +} + +// When index is -1 index chooses the current tab +void TabWidget::cloneTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + WebView *tab = newTab(false); + tab->setUrl(webView(index)->url()); +} + +// When index is -1 index chooses the current tab +void TabWidget::closeTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + bool hasFocus = false; + if (WebView *tab = webView(index)) { + if (tab->isModified()) { + QMessageBox closeConfirmation(tab); + closeConfirmation.setWindowFlags(Qt::Sheet); + closeConfirmation.setWindowTitle(tr("Do you really want to close this page?")); + closeConfirmation.setInformativeText(tr("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n")); + closeConfirmation.setIcon(QMessageBox::Question); + closeConfirmation.addButton(QMessageBox::Yes); + closeConfirmation.addButton(QMessageBox::No); + closeConfirmation.setEscapeButton(QMessageBox::No); + if (closeConfirmation.exec() == QMessageBox::No) + return; + } + hasFocus = tab->hasFocus(); + + m_recentlyClosedTabsAction->setEnabled(true); + m_recentlyClosedTabs.prepend(tab->url()); + if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize) + m_recentlyClosedTabs.removeLast(); + } + QWidget *lineEdit = m_lineEdits->widget(index); + m_lineEdits->removeWidget(lineEdit); + lineEdit->deleteLater(); + QWidget *webView = widget(index); + removeTab(index); + webView->deleteLater(); + emit tabsChanged(); + if (hasFocus && count() > 0) + currentWebView()->setFocus(); + if (count() == 0) + emit lastTabClosed(); +} + +void TabWidget::webViewLoadStarted() +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + QIcon icon(QLatin1String(":loading.gif")); + setTabIcon(index, icon); + } +} + +void TabWidget::webViewIconChanged() +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + QIcon icon = BrowserApplication::instance()->icon(webView->url()); + setTabIcon(index, icon); + } +} + +void TabWidget::webViewTitleChanged(const QString &title) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + setTabText(index, title); + } + if (currentIndex() == index) + emit setCurrentTitle(title); + BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); +} + +void TabWidget::webViewUrlChanged(const QUrl &url) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + m_tabBar->setTabData(index, url); + } + emit tabsChanged(); +} + +void TabWidget::aboutToShowRecentTabsMenu() +{ + m_recentlyClosedTabsMenu->clear(); + for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) { + QAction *action = new QAction(m_recentlyClosedTabsMenu); + action->setData(m_recentlyClosedTabs.at(i)); + QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); + action->setIcon(icon); + action->setText(m_recentlyClosedTabs.at(i).toString()); + m_recentlyClosedTabsMenu->addAction(action); + } +} + +void TabWidget::aboutToShowRecentTriggeredAction(QAction *action) +{ + QUrl url = action->data().toUrl(); + loadUrlInCurrentTab(url); +} + +void TabWidget::mouseDoubleClickEvent(QMouseEvent *event) +{ + if (!childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { + newTab(); + return; + } + QTabWidget::mouseDoubleClickEvent(event); +} + +void TabWidget::contextMenuEvent(QContextMenuEvent *event) +{ + if (!childAt(event->pos())) { + m_tabBar->contextMenuRequested(event->pos()); + return; + } + QTabWidget::contextMenuEvent(event); +} + +void TabWidget::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::MidButton && !childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { + QUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { + WebView *webView = newTab(); + webView->setUrl(url); + } + } +} + +void TabWidget::loadUrlInCurrentTab(const QUrl &url) +{ + WebView *webView = currentWebView(); + if (webView) { + webView->loadUrl(url); + webView->setFocus(); + } +} + +void TabWidget::nextTab() +{ + int next = currentIndex() + 1; + if (next == count()) + next = 0; + setCurrentIndex(next); +} + +void TabWidget::previousTab() +{ + int next = currentIndex() - 1; + if (next < 0) + next = count() - 1; + setCurrentIndex(next); +} + +static const qint32 TabWidgetMagic = 0xaa; + +QByteArray TabWidget::saveState() const +{ + int version = 1; + QByteArray data; + QDataStream stream(&data, QIODevice::WriteOnly); + + stream << qint32(TabWidgetMagic); + stream << qint32(version); + + QStringList tabs; + for (int i = 0; i < count(); ++i) { + if (WebView *tab = qobject_cast(widget(i))) { + tabs.append(tab->url().toString()); + } else { + tabs.append(QString::null); + } + } + stream << tabs; + stream << currentIndex(); + return data; +} + +bool TabWidget::restoreState(const QByteArray &state) +{ + int version = 1; + QByteArray sd = state; + QDataStream stream(&sd, QIODevice::ReadOnly); + if (stream.atEnd()) + return false; + + qint32 marker; + qint32 v; + stream >> marker; + stream >> v; + if (marker != TabWidgetMagic || v != version) + return false; + + QStringList openTabs; + stream >> openTabs; + + for (int i = 0; i < openTabs.count(); ++i) { + if (i != 0) + newTab(); + loadPage(openTabs.at(i)); + } + + int currentTab; + stream >> currentTab; + setCurrentIndex(currentTab); + + return true; +} + +WebActionMapper::WebActionMapper(QAction *root, QWebPage::WebAction webAction, QObject *parent) + : QObject(parent) + , m_currentParent(0) + , m_root(root) + , m_webAction(webAction) +{ + if (!m_root) + return; + connect(m_root, SIGNAL(triggered()), this, SLOT(rootTriggered())); + connect(root, SIGNAL(destroyed(QObject *)), this, SLOT(rootDestroyed())); + root->setEnabled(false); +} + +void WebActionMapper::rootDestroyed() +{ + m_root = 0; +} + +void WebActionMapper::currentDestroyed() +{ + updateCurrent(0); +} + +void WebActionMapper::addChild(QAction *action) +{ + if (!action) + return; + connect(action, SIGNAL(changed()), this, SLOT(childChanged())); +} + +QWebPage::WebAction WebActionMapper::webAction() const +{ + return m_webAction; +} + +void WebActionMapper::rootTriggered() +{ + if (m_currentParent) { + QAction *gotoAction = m_currentParent->action(m_webAction); + gotoAction->trigger(); + } +} + +void WebActionMapper::childChanged() +{ + if (QAction *source = qobject_cast(sender())) { + if (m_root + && m_currentParent + && source->parent() == m_currentParent) { + m_root->setChecked(source->isChecked()); + m_root->setEnabled(source->isEnabled()); + } + } +} + +void WebActionMapper::updateCurrent(QWebPage *currentParent) +{ + if (m_currentParent) + disconnect(m_currentParent, SIGNAL(destroyed(QObject *)), + this, SLOT(currentDestroyed())); + + m_currentParent = currentParent; + if (!m_root) + return; + if (!m_currentParent) { + m_root->setEnabled(false); + m_root->setChecked(false); + return; + } + QAction *source = m_currentParent->action(m_webAction); + m_root->setChecked(source->isChecked()); + m_root->setEnabled(source->isEnabled()); + connect(m_currentParent, SIGNAL(destroyed(QObject *)), + this, SLOT(currentDestroyed())); +} diff --git a/src/tabwidget.h b/src/tabwidget.h new file mode 100644 index 00000000..1bdd56bf --- /dev/null +++ b/src/tabwidget.h @@ -0,0 +1,222 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef TABWIDGET_H +#define TABWIDGET_H + +#include + +#include +/* + Tab bar with a few more features such as a context menu and shortcuts + */ +class TabBar : public QTabBar +{ + Q_OBJECT + +signals: + void newTab(); + void cloneTab(int index); + void closeTab(int index); + void closeOtherTabs(int index); + void reloadTab(int index); + void reloadAllTabs(); + void tabMoveRequested(int fromIndex, int toIndex); + +public: + TabBar(QWidget *parent = 0); + +protected: + void mousePressEvent(QMouseEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + +private slots: + void selectTabAction(); + void cloneTab(); + void closeTab(); + void closeOtherTabs(); + void reloadTab(); + void contextMenuRequested(const QPoint &position); + +private: + QList m_tabShortcuts; + friend class TabWidget; + + QPoint m_dragStartPos; + int m_dragCurrentIndex; +}; + +#include + +QT_BEGIN_NAMESPACE +class QAction; +QT_END_NAMESPACE +class WebView; +/*! + A proxy object that connects a single browser action + to one child webpage action at a time. + + Example usage: used to keep the main window stop action in sync with + the current tabs webview's stop action. + */ +class WebActionMapper : public QObject +{ + Q_OBJECT + +public: + WebActionMapper(QAction *root, QWebPage::WebAction webAction, QObject *parent); + QWebPage::WebAction webAction() const; + void addChild(QAction *action); + void updateCurrent(QWebPage *currentParent); + +private slots: + void rootTriggered(); + void childChanged(); + void rootDestroyed(); + void currentDestroyed(); + +private: + QWebPage *m_currentParent; + QAction *m_root; + QWebPage::WebAction m_webAction; +}; + +#include +#include +QT_BEGIN_NAMESPACE +class QCompleter; +class QLineEdit; +class QMenu; +class QStackedWidget; +QT_END_NAMESPACE +/*! + TabWidget that contains WebViews and a stack widget of associated line edits. + + Connects up the current tab's signals to this class's signal and uses WebActionMapper + to proxy the actions. + */ +class TabWidget : public QTabWidget +{ + Q_OBJECT + +signals: + // tab widget signals + void loadPage(const QString &url); + void tabsChanged(); + void lastTabClosed(); + + // current tab signals + void setCurrentTitle(const QString &url); + void showStatusBarMessage(const QString &message); + void linkHovered(const QString &link); + void loadProgress(int progress); + void geometryChangeRequested(const QRect &geometry); + void menuBarVisibilityChangeRequested(bool visible); + void statusBarVisibilityChangeRequested(bool visible); + void toolBarVisibilityChangeRequested(bool visible); + void printRequested(QWebFrame *frame); + +public: + TabWidget(QWidget *parent = 0); + void clear(); + void addWebAction(QAction *action, QWebPage::WebAction webAction); + + QAction *newTabAction() const; + QAction *closeTabAction() const; + QAction *recentlyClosedTabsAction() const; + QAction *nextTabAction() const; + QAction *previousTabAction() const; + + QWidget *lineEditStack() const; + QLineEdit *currentLineEdit() const; + WebView *currentWebView() const; + WebView *webView(int index) const; + QLineEdit *lineEdit(int index) const; + int webViewIndex(WebView *webView) const; + + QByteArray saveState() const; + bool restoreState(const QByteArray &state); + +protected: + void mouseDoubleClickEvent(QMouseEvent *event); + void contextMenuEvent(QContextMenuEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + +public slots: + void loadUrlInCurrentTab(const QUrl &url); + WebView *newTab(bool makeCurrent = true); + void cloneTab(int index = -1); + void closeTab(int index = -1); + void closeOtherTabs(int index); + void reloadTab(int index = -1); + void reloadAllTabs(); + void nextTab(); + void previousTab(); + +private slots: + void currentChanged(int index); + void aboutToShowRecentTabsMenu(); + void aboutToShowRecentTriggeredAction(QAction *action); + void webViewLoadStarted(); + void webViewIconChanged(); + void webViewTitleChanged(const QString &title); + void webViewUrlChanged(const QUrl &url); + void lineEditReturnPressed(); + void windowCloseRequested(); + void moveTab(int fromIndex, int toIndex); + +private: + QAction *m_recentlyClosedTabsAction; + QAction *m_newTabAction; + QAction *m_closeTabAction; + QAction *m_nextTabAction; + QAction *m_previousTabAction; + + QMenu *m_recentlyClosedTabsMenu; + static const int m_recentlyClosedTabsSize = 10; + QList m_recentlyClosedTabs; + QList m_actions; + + QCompleter *m_lineEditCompleter; + QStackedWidget *m_lineEdits; + TabBar *m_tabBar; +}; + +#endif // TABWIDGET_H + diff --git a/src/toolbarsearch.cpp b/src/toolbarsearch.cpp new file mode 100644 index 00000000..16022fe0 --- /dev/null +++ b/src/toolbarsearch.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "toolbarsearch.h" +#include "autosaver.h" + +#include +#include + +#include +#include +#include + +#include + +/* + ToolbarSearch is a very basic search widget that also contains a small history. + Searches are turned into urls that use Google to perform search + */ +ToolbarSearch::ToolbarSearch(QWidget *parent) + : SearchLineEdit(parent) + , m_autosaver(new AutoSaver(this)) + , m_maxSavedSearches(10) + , m_stringListModel(new QStringListModel(this)) +{ + QMenu *m = menu(); + connect(m, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu())); + connect(m, SIGNAL(triggered(QAction*)), this, SLOT(triggeredMenuAction(QAction*))); + + QCompleter *completer = new QCompleter(m_stringListModel, this); + completer->setCompletionMode(QCompleter::InlineCompletion); + lineEdit()->setCompleter(completer); + + connect(lineEdit(), SIGNAL(returnPressed()), SLOT(searchNow())); + setInactiveText(tr("Google")); + load(); +} + +ToolbarSearch::~ToolbarSearch() +{ + m_autosaver->saveIfNeccessary(); +} + +void ToolbarSearch::save() +{ + QSettings settings; + settings.beginGroup(QLatin1String("toolbarsearch")); + settings.setValue(QLatin1String("recentSearches"), m_stringListModel->stringList()); + settings.setValue(QLatin1String("maximumSaved"), m_maxSavedSearches); + settings.endGroup(); +} + +void ToolbarSearch::load() +{ + QSettings settings; + settings.beginGroup(QLatin1String("toolbarsearch")); + QStringList list = settings.value(QLatin1String("recentSearches")).toStringList(); + m_maxSavedSearches = settings.value(QLatin1String("maximumSaved"), m_maxSavedSearches).toInt(); + m_stringListModel->setStringList(list); + settings.endGroup(); +} + +void ToolbarSearch::searchNow() +{ + QString searchText = lineEdit()->text(); + QStringList newList = m_stringListModel->stringList(); + if (newList.contains(searchText)) + newList.removeAt(newList.indexOf(searchText)); + newList.prepend(searchText); + if (newList.size() >= m_maxSavedSearches) + newList.removeLast(); + + QWebSettings *globalSettings = QWebSettings::globalSettings(); + if (!globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { + m_stringListModel->setStringList(newList); + m_autosaver->changeOccurred(); + } + + QUrl url(QLatin1String("http://www.google.com/search")); + url.addQueryItem(QLatin1String("q"), searchText); + url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); + url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); + url.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser")); + emit search(url); +} + +void ToolbarSearch::aboutToShowMenu() +{ + lineEdit()->selectAll(); + QMenu *m = menu(); + m->clear(); + QStringList list = m_stringListModel->stringList(); + if (list.isEmpty()) { + m->addAction(tr("No Recent Searches")); + return; + } + + QAction *recent = m->addAction(tr("Recent Searches")); + recent->setEnabled(false); + for (int i = 0; i < list.count(); ++i) { + QString text = list.at(i); + m->addAction(text)->setData(text); + } + m->addSeparator(); + m->addAction(tr("Clear Recent Searches"), this, SLOT(clear())); +} + +void ToolbarSearch::triggeredMenuAction(QAction *action) +{ + QVariant v = action->data(); + if (v.canConvert()) { + QString text = v.toString(); + lineEdit()->setText(text); + searchNow(); + } +} + +void ToolbarSearch::clear() +{ + m_stringListModel->setStringList(QStringList()); + m_autosaver->changeOccurred();; +} diff --git a/src/toolbarsearch.h b/src/toolbarsearch.h new file mode 100644 index 00000000..9ecbf183 --- /dev/null +++ b/src/toolbarsearch.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef TOOLBARSEARCH_H +#define TOOLBARSEARCH_H + +#include "searchlineedit.h" + +QT_BEGIN_NAMESPACE +class QUrl; +class QAction; +class QStringListModel; +QT_END_NAMESPACE + +class AutoSaver; + +class ToolbarSearch : public SearchLineEdit +{ + Q_OBJECT + +signals: + void search(const QUrl &url); + +public: + ToolbarSearch(QWidget *parent = 0); + ~ToolbarSearch(); + +public slots: + void clear(); + void searchNow(); + +private slots: + void save(); + void aboutToShowMenu(); + void triggeredMenuAction(QAction *action); + +private: + void load(); + + AutoSaver *m_autosaver; + int m_maxSavedSearches; + QStringListModel *m_stringListModel; +}; + +#endif // TOOLBARSEARCH_H + diff --git a/src/urllineedit.cpp b/src/urllineedit.cpp new file mode 100644 index 00000000..47900c04 --- /dev/null +++ b/src/urllineedit.cpp @@ -0,0 +1,327 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "urllineedit.h" + +#include "browserapplication.h" +#include "searchlineedit.h" +#include "webview.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +ExLineEdit::ExLineEdit(QWidget *parent) + : QWidget(parent) + , m_leftWidget(0) + , m_lineEdit(new QLineEdit(this)) + , m_clearButton(0) +{ + setFocusPolicy(m_lineEdit->focusPolicy()); + setAttribute(Qt::WA_InputMethodEnabled); + setSizePolicy(m_lineEdit->sizePolicy()); + setBackgroundRole(m_lineEdit->backgroundRole()); + setMouseTracking(true); + setAcceptDrops(true); + setAttribute(Qt::WA_MacShowFocusRect, true); + QPalette p = m_lineEdit->palette(); + setPalette(p); + + // line edit + m_lineEdit->setFrame(false); + m_lineEdit->setFocusProxy(this); + m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); + QPalette clearPalette = m_lineEdit->palette(); + clearPalette.setBrush(QPalette::Base, QBrush(Qt::transparent)); + m_lineEdit->setPalette(clearPalette); + + // clearButton + m_clearButton = new ClearButton(this); + connect(m_clearButton, SIGNAL(clicked()), + m_lineEdit, SLOT(clear())); + connect(m_lineEdit, SIGNAL(textChanged(const QString&)), + m_clearButton, SLOT(textChanged(const QString&))); +} + +void ExLineEdit::setLeftWidget(QWidget *widget) +{ + m_leftWidget = widget; +} + +QWidget *ExLineEdit::leftWidget() const +{ + return m_leftWidget; +} + +void ExLineEdit::resizeEvent(QResizeEvent *event) +{ + Q_ASSERT(m_leftWidget); + updateGeometries(); + QWidget::resizeEvent(event); +} + +void ExLineEdit::updateGeometries() +{ + QStyleOptionFrameV2 panel; + initStyleOption(&panel); + QRect rect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); + + int height = rect.height(); + int width = rect.width(); + + int m_leftWidgetHeight = m_leftWidget->height(); + m_leftWidget->setGeometry(rect.x() + 2, rect.y() + (height - m_leftWidgetHeight)/2, + m_leftWidget->width(), m_leftWidget->height()); + + int clearButtonWidth = this->height(); + m_lineEdit->setGeometry(m_leftWidget->x() + m_leftWidget->width(), 0, + width - clearButtonWidth - m_leftWidget->width(), this->height()); + + m_clearButton->setGeometry(this->width() - clearButtonWidth, 0, + clearButtonWidth, this->height()); +} + +void ExLineEdit::initStyleOption(QStyleOptionFrameV2 *option) const +{ + option->initFrom(this); + option->rect = contentsRect(); + option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this); + option->midLineWidth = 0; + option->state |= QStyle::State_Sunken; + if (m_lineEdit->isReadOnly()) + option->state |= QStyle::State_ReadOnly; +#ifdef QT_KEYPAD_NAVIGATION + if (hasEditFocus()) + option->state |= QStyle::State_HasEditFocus; +#endif + option->features = QStyleOptionFrameV2::None; +} + +QSize ExLineEdit::sizeHint() const +{ + m_lineEdit->setFrame(true); + QSize size = m_lineEdit->sizeHint(); + m_lineEdit->setFrame(false); + return size; +} + +void ExLineEdit::focusInEvent(QFocusEvent *event) +{ + m_lineEdit->event(event); + QWidget::focusInEvent(event); +} + +void ExLineEdit::focusOutEvent(QFocusEvent *event) +{ + m_lineEdit->event(event); + + if (m_lineEdit->completer()) { + connect(m_lineEdit->completer(), SIGNAL(activated(QString)), + m_lineEdit, SLOT(setText(QString))); + connect(m_lineEdit->completer(), SIGNAL(highlighted(QString)), + m_lineEdit, SLOT(_q_completionHighlighted(QString))); + } + QWidget::focusOutEvent(event); +} + +void ExLineEdit::keyPressEvent(QKeyEvent *event) +{ + m_lineEdit->event(event); + QWidget::keyPressEvent(event); +} + +bool ExLineEdit::event(QEvent *event) +{ + if (event->type() == QEvent::ShortcutOverride) + m_lineEdit->event(event); + return QWidget::event(event); +} + +void ExLineEdit::paintEvent(QPaintEvent *) +{ + QPainter p(this); + QStyleOptionFrameV2 panel; + initStyleOption(&panel); + style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this); +} + + +class UrlIconLabel : public QLabel +{ + +public: + UrlIconLabel(QWidget *parent); + + WebView *m_webView; + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + +private: + QPoint m_dragStartPos; + +}; + +UrlIconLabel::UrlIconLabel(QWidget *parent) + : QLabel(parent) + , m_webView(0) +{ + setMinimumWidth(16); + setMinimumHeight(16); +} + +void UrlIconLabel::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + m_dragStartPos = event->pos(); + QLabel::mousePressEvent(event); +} + +void UrlIconLabel::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() == Qt::LeftButton + && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance() + && m_webView) { + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + mimeData->setText(m_webView->url().toString()); + QList urls; + urls.append(m_webView->url()); + mimeData->setUrls(urls); + drag->setMimeData(mimeData); + drag->exec(); + } +} + +UrlLineEdit::UrlLineEdit(QWidget *parent) + : ExLineEdit(parent) + , m_webView(0) + , m_iconLabel(0) +{ + // icon + m_iconLabel = new UrlIconLabel(this); + m_iconLabel->resize(16, 16); + setLeftWidget(m_iconLabel); + m_defaultBaseColor = palette().color(QPalette::Base); + + webViewIconChanged(); +} + +void UrlLineEdit::setWebView(WebView *webView) +{ + Q_ASSERT(!m_webView); + m_webView = webView; + m_iconLabel->m_webView = webView; + connect(webView, SIGNAL(urlChanged(const QUrl &)), + this, SLOT(webViewUrlChanged(const QUrl &))); + connect(webView, SIGNAL(loadFinished(bool)), + this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged()), + this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(loadProgress(int)), + this, SLOT(update())); +} + +void UrlLineEdit::webViewUrlChanged(const QUrl &url) +{ + m_lineEdit->setText(url.toString()); + m_lineEdit->setCursorPosition(0); +} + +void UrlLineEdit::webViewIconChanged() +{ + QUrl url = (m_webView) ? m_webView->url() : QUrl(); + QIcon icon = BrowserApplication::instance()->icon(url); + QPixmap pixmap(icon.pixmap(16, 16)); + m_iconLabel->setPixmap(pixmap); +} + +QLinearGradient UrlLineEdit::generateGradient(const QColor &color) const +{ + QLinearGradient gradient(0, 0, 0, height()); + gradient.setColorAt(0, m_defaultBaseColor); + gradient.setColorAt(0.15, color.lighter(120)); + gradient.setColorAt(0.5, color); + gradient.setColorAt(0.85, color.lighter(120)); + gradient.setColorAt(1, m_defaultBaseColor); + return gradient; +} + +void UrlLineEdit::focusOutEvent(QFocusEvent *event) +{ + if (m_lineEdit->text().isEmpty() && m_webView) + m_lineEdit->setText(m_webView->url().toString()); + ExLineEdit::focusOutEvent(event); +} + +void UrlLineEdit::paintEvent(QPaintEvent *event) +{ + QPalette p = palette(); + if (m_webView && m_webView->url().scheme() == QLatin1String("https")) { + QColor lightYellow(248, 248, 210); + p.setBrush(QPalette::Base, generateGradient(lightYellow)); + } else { + p.setBrush(QPalette::Base, m_defaultBaseColor); + } + setPalette(p); + ExLineEdit::paintEvent(event); + + QPainter painter(this); + QStyleOptionFrameV2 panel; + initStyleOption(&panel); + QRect backgroundRect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); + if (m_webView && !hasFocus()) { + int progress = m_webView->progress(); + QColor loadingColor = QColor(116, 192, 250); + painter.setBrush(generateGradient(loadingColor)); + painter.setPen(Qt::transparent); + int mid = backgroundRect.width() / 100 * progress; + QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); + painter.drawRect(progressRect); + } +} diff --git a/src/urllineedit.h b/src/urllineedit.h new file mode 100644 index 00000000..283ff48e --- /dev/null +++ b/src/urllineedit.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef URLLINEEDIT_H +#define URLLINEEDIT_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QLineEdit; +QT_END_NAMESPACE + +class ClearButton; +class ExLineEdit : public QWidget +{ + Q_OBJECT + +public: + ExLineEdit(QWidget *parent = 0); + + inline QLineEdit *lineEdit() const { return m_lineEdit; } + + void setLeftWidget(QWidget *widget); + QWidget *leftWidget() const; + + QSize sizeHint() const; + +protected: + void focusInEvent(QFocusEvent *event); + void focusOutEvent(QFocusEvent *event); + void keyPressEvent(QKeyEvent *event); + void paintEvent(QPaintEvent *event); + void resizeEvent(QResizeEvent *event); + bool event(QEvent *event); + +protected: + void updateGeometries(); + void initStyleOption(QStyleOptionFrameV2 *option) const; + + QWidget *m_leftWidget; + QLineEdit *m_lineEdit; + ClearButton *m_clearButton; +}; + +class UrlIconLabel; +class WebView; +class UrlLineEdit : public ExLineEdit +{ + Q_OBJECT + +public: + UrlLineEdit(QWidget *parent = 0); + void setWebView(WebView *webView); + +protected: + void paintEvent(QPaintEvent *event); + void focusOutEvent(QFocusEvent *event); + +private slots: + void webViewUrlChanged(const QUrl &url); + void webViewIconChanged(); + +private: + QLinearGradient generateGradient(const QColor &color) const; + WebView *m_webView; + UrlIconLabel *m_iconLabel; + QColor m_defaultBaseColor; + +}; + + +#endif // URLLINEEDIT_H + diff --git a/src/webview.cpp b/src/webview.cpp new file mode 100644 index 00000000..39cedd95 --- /dev/null +++ b/src/webview.cpp @@ -0,0 +1,299 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "browserapplication.h" +#include "browsermainwindow.h" +#include "cookiejar.h" +#include "downloadmanager.h" +#include "networkaccessmanager.h" +#include "tabwidget.h" +#include "webview.h" + +#include +#include +#include +#include + +#include + +#include + +#include +#include + +WebPage::WebPage(QObject *parent) + : QWebPage(parent) + , m_keyboardModifiers(Qt::NoModifier) + , m_pressedButtons(Qt::NoButton) + , m_openInNewTab(false) +{ + setNetworkAccessManager(BrowserApplication::networkAccessManager()); + connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), + this, SLOT(handleUnsupportedContent(QNetworkReply *))); +} + +BrowserMainWindow *WebPage::mainWindow() +{ + QObject *w = this->parent(); + while (w) { + if (BrowserMainWindow *mw = qobject_cast(w)) + return mw; + w = w->parent(); + } + return BrowserApplication::instance()->mainWindow(); +} + +bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) +{ + // ctrl open in new tab + // ctrl-shift open in new tab and select + // ctrl-alt open in new window + if (type == QWebPage::NavigationTypeLinkClicked + && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton)) { + bool newWindow = (m_keyboardModifiers & Qt::AltModifier); + WebView *webView; + if (newWindow) { + BrowserApplication::instance()->newMainWindow(); + BrowserMainWindow *newMainWindow = BrowserApplication::instance()->mainWindow(); + webView = newMainWindow->currentTab(); + newMainWindow->raise(); + newMainWindow->activateWindow(); + webView->setFocus(); + } else { + bool selectNewTab = (m_keyboardModifiers & Qt::ShiftModifier); + webView = mainWindow()->tabWidget()->newTab(selectNewTab); + } + webView->load(request); + m_keyboardModifiers = Qt::NoModifier; + m_pressedButtons = Qt::NoButton; + return false; + } + if (frame == mainFrame()) { + m_loadingUrl = request.url(); + emit loadingUrl(m_loadingUrl); + } + return QWebPage::acceptNavigationRequest(frame, request, type); +} + +QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) +{ + Q_UNUSED(type); + if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) + m_openInNewTab = true; + if (m_openInNewTab) { + m_openInNewTab = false; + return mainWindow()->tabWidget()->newTab()->page(); + } + BrowserApplication::instance()->newMainWindow(); + BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + return mainWindow->currentTab()->page(); +} + +#if !defined(QT_NO_UITOOLS) +QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +{ + Q_UNUSED(url); + Q_UNUSED(paramNames); + Q_UNUSED(paramValues); + QUiLoader loader; + return loader.createWidget(classId, view()); +} +#endif // !defined(QT_NO_UITOOLS) + +void WebPage::handleUnsupportedContent(QNetworkReply *reply) +{ + if (reply->error() == QNetworkReply::NoError) { + BrowserApplication::downloadManager()->handleUnsupportedContent(reply); + return; + } + + QFile file(QLatin1String(":/notfound.html")); + bool isOpened = file.open(QIODevice::ReadOnly); + Q_ASSERT(isOpened); + QString title = tr("Error loading page: %1").arg(reply->url().toString()); + QString html = QString(QLatin1String(file.readAll())) + .arg(title) + .arg(reply->errorString()) + .arg(reply->url().toString()); + + QBuffer imageBuffer; + imageBuffer.open(QBuffer::ReadWrite); + QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view()); + QPixmap pixmap = icon.pixmap(QSize(32,32)); + if (pixmap.save(&imageBuffer, "PNG")) { + html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"), + QString(QLatin1String(imageBuffer.buffer().toBase64()))); + } + + QList frames; + frames.append(mainFrame()); + while (!frames.isEmpty()) { + QWebFrame *frame = frames.takeFirst(); + if (frame->url() == reply->url()) { + frame->setHtml(html, reply->url()); + return; + } + QList children = frame->childFrames(); + foreach(QWebFrame *frame, children) + frames.append(frame); + } + if (m_loadingUrl == reply->url()) { + mainFrame()->setHtml(html, reply->url()); + } +} + + +WebView::WebView(QWidget* parent) + : QWebView(parent) + , m_progress(0) + , m_page(new WebPage(this)) +{ + setPage(m_page); + connect(page(), SIGNAL(statusBarMessage(const QString&)), + SLOT(setStatusBarText(const QString&))); + connect(this, SIGNAL(loadProgress(int)), + this, SLOT(setProgress(int))); + connect(this, SIGNAL(loadFinished(bool)), + this, SLOT(loadFinished())); + connect(page(), SIGNAL(loadingUrl(const QUrl&)), + this, SIGNAL(urlChanged(const QUrl &))); + connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), + this, SLOT(downloadRequested(const QNetworkRequest &))); + page()->setForwardUnsupportedContent(true); + +} + +void WebView::contextMenuEvent(QContextMenuEvent *event) +{ + QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); + if (!r.linkUrl().isEmpty()) { + QMenu menu(this); + menu.addAction(pageAction(QWebPage::OpenLinkInNewWindow)); + menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab())); + menu.addSeparator(); + menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); + // Add link to bookmarks... + menu.addSeparator(); + menu.addAction(pageAction(QWebPage::CopyLinkToClipboard)); + if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) + menu.addAction(pageAction(QWebPage::InspectElement)); + menu.exec(mapToGlobal(event->pos())); + return; + } + QWebView::contextMenuEvent(event); +} + +void WebView::wheelEvent(QWheelEvent *event) +{ + if (QApplication::keyboardModifiers() & Qt::ControlModifier) { + int numDegrees = event->delta() / 8; + int numSteps = numDegrees / 15; + setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1); + event->accept(); + return; + } + QWebView::wheelEvent(event); +} + +void WebView::openLinkInNewTab() +{ + m_page->m_openInNewTab = true; + pageAction(QWebPage::OpenLinkInNewWindow)->trigger(); +} + +void WebView::setProgress(int progress) +{ + m_progress = progress; +} + +void WebView::loadFinished() +{ + if (100 != m_progress) { + qWarning() << "Recieved finished signal while progress is still:" << progress() + << "Url:" << url(); + } + m_progress = 0; +} + +void WebView::loadUrl(const QUrl &url) +{ + m_initialUrl = url; + load(url); +} + +QString WebView::lastStatusBarText() const +{ + return m_statusBarText; +} + +QUrl WebView::url() const +{ + QUrl url = QWebView::url(); + if (!url.isEmpty()) + return url; + + return m_initialUrl; +} + +void WebView::mousePressEvent(QMouseEvent *event) +{ + m_page->m_pressedButtons = event->buttons(); + m_page->m_keyboardModifiers = event->modifiers(); + QWebView::mousePressEvent(event); +} + +void WebView::mouseReleaseEvent(QMouseEvent *event) +{ + QWebView::mouseReleaseEvent(event); + if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) { + QUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { + setUrl(url); + } + } +} + +void WebView::setStatusBarText(const QString &string) +{ + m_statusBarText = string; +} + +void WebView::downloadRequested(const QNetworkRequest &request) +{ + BrowserApplication::downloadManager()->download(request); +} diff --git a/src/webview.h b/src/webview.h new file mode 100644 index 00000000..73c9dafb --- /dev/null +++ b/src/webview.h @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef WEBVIEW_H +#define WEBVIEW_H + +#include + +QT_BEGIN_NAMESPACE +class QAuthenticator; +class QMouseEvent; +class QNetworkProxy; +class QNetworkReply; +class QSslError; +QT_END_NAMESPACE + +class BrowserMainWindow; +class WebPage : public QWebPage { + Q_OBJECT + +signals: + void loadingUrl(const QUrl &url); + +public: + WebPage(QObject *parent = 0); + BrowserMainWindow *mainWindow(); + +protected: + bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); + QWebPage *createWindow(QWebPage::WebWindowType type); +#if !defined(QT_NO_UITOOLS) + QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); +#endif + +private slots: + void handleUnsupportedContent(QNetworkReply *reply); + +private: + friend class WebView; + + // set the webview mousepressedevent + Qt::KeyboardModifiers m_keyboardModifiers; + Qt::MouseButtons m_pressedButtons; + bool m_openInNewTab; + QUrl m_loadingUrl; +}; + +class WebView : public QWebView { + Q_OBJECT + +public: + WebView(QWidget *parent = 0); + WebPage *webPage() const { return m_page; } + + void loadUrl(const QUrl &url); + QUrl url() const; + + QString lastStatusBarText() const; + inline int progress() const { return m_progress; } + +protected: + void mousePressEvent(QMouseEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + void contextMenuEvent(QContextMenuEvent *event); + void wheelEvent(QWheelEvent *event); + +private slots: + void setProgress(int progress); + void loadFinished(); + void setStatusBarText(const QString &string); + void downloadRequested(const QNetworkRequest &request); + void openLinkInNewTab(); + +private: + QString m_statusBarText; + QUrl m_initialUrl; + int m_progress; + WebPage *m_page; +}; + +#endif diff --git a/src/xbel.cpp b/src/xbel.cpp new file mode 100644 index 00000000..3accd76d --- /dev/null +++ b/src/xbel.cpp @@ -0,0 +1,315 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include "xbel.h" + +#include + +BookmarkNode::BookmarkNode(BookmarkNode::Type type, BookmarkNode *parent) : + expanded(false) + , m_parent(parent) + , m_type(type) +{ + if (parent) + parent->add(this); +} + +BookmarkNode::~BookmarkNode() +{ + if (m_parent) + m_parent->remove(this); + qDeleteAll(m_children); + m_parent = 0; + m_type = BookmarkNode::Root; +} + +bool BookmarkNode::operator==(const BookmarkNode &other) +{ + if (url != other.url + || title != other.title + || desc != other.desc + || expanded != other.expanded + || m_type != other.m_type + || m_children.count() != other.m_children.count()) + return false; + + for (int i = 0; i < m_children.count(); ++i) + if (!((*(m_children[i])) == (*(other.m_children[i])))) + return false; + return true; +} + +BookmarkNode::Type BookmarkNode::type() const +{ + return m_type; +} + +void BookmarkNode::setType(Type type) +{ + m_type = type; +} + +QList BookmarkNode::children() const +{ + return m_children; +} + +BookmarkNode *BookmarkNode::parent() const +{ + return m_parent; +} + +void BookmarkNode::add(BookmarkNode *child, int offset) +{ + Q_ASSERT(child->m_type != Root); + if (child->m_parent) + child->m_parent->remove(child); + child->m_parent = this; + if (-1 == offset) + offset = m_children.size(); + m_children.insert(offset, child); +} + +void BookmarkNode::remove(BookmarkNode *child) +{ + child->m_parent = 0; + m_children.removeAll(child); +} + + +XbelReader::XbelReader() +{ +} + +BookmarkNode *XbelReader::read(const QString &fileName) +{ + QFile file(fileName); + if (!file.exists()) { + return new BookmarkNode(BookmarkNode::Root); + } + file.open(QFile::ReadOnly); + return read(&file); +} + +BookmarkNode *XbelReader::read(QIODevice *device) +{ + BookmarkNode *root = new BookmarkNode(BookmarkNode::Root); + setDevice(device); + while (!atEnd()) { + readNext(); + if (isStartElement()) { + QString version = attributes().value(QLatin1String("version")).toString(); + if (name() == QLatin1String("xbel") + && (version.isEmpty() || version == QLatin1String("1.0"))) { + readXBEL(root); + } else { + raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); + } + } + } + return root; +} + +void XbelReader::readXBEL(BookmarkNode *parent) +{ + Q_ASSERT(isStartElement() && name() == QLatin1String("xbel")); + + while (!atEnd()) { + readNext(); + if (isEndElement()) + break; + + if (isStartElement()) { + if (name() == QLatin1String("folder")) + readFolder(parent); + else if (name() == QLatin1String("bookmark")) + readBookmarkNode(parent); + else if (name() == QLatin1String("separator")) + readSeparator(parent); + else + skipUnknownElement(); + } + } +} + +void XbelReader::readFolder(BookmarkNode *parent) +{ + Q_ASSERT(isStartElement() && name() == QLatin1String("folder")); + + BookmarkNode *folder = new BookmarkNode(BookmarkNode::Folder, parent); + folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no")); + + while (!atEnd()) { + readNext(); + + if (isEndElement()) + break; + + if (isStartElement()) { + if (name() == QLatin1String("title")) + readTitle(folder); + else if (name() == QLatin1String("desc")) + readDescription(folder); + else if (name() == QLatin1String("folder")) + readFolder(folder); + else if (name() == QLatin1String("bookmark")) + readBookmarkNode(folder); + else if (name() == QLatin1String("separator")) + readSeparator(folder); + else + skipUnknownElement(); + } + } +} + +void XbelReader::readTitle(BookmarkNode *parent) +{ + Q_ASSERT(isStartElement() && name() == QLatin1String("title")); + parent->title = readElementText(); +} + +void XbelReader::readDescription(BookmarkNode *parent) +{ + Q_ASSERT(isStartElement() && name() == QLatin1String("desc")); + parent->desc = readElementText(); +} + +void XbelReader::readSeparator(BookmarkNode *parent) +{ + new BookmarkNode(BookmarkNode::Separator, parent); + // empty elements have a start and end element + readNext(); +} + +void XbelReader::readBookmarkNode(BookmarkNode *parent) +{ + Q_ASSERT(isStartElement() && name() == QLatin1String("bookmark")); + BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark, parent); + bookmark->url = attributes().value(QLatin1String("href")).toString(); + while (!atEnd()) { + readNext(); + if (isEndElement()) + break; + + if (isStartElement()) { + if (name() == QLatin1String("title")) + readTitle(bookmark); + else if (name() == QLatin1String("desc")) + readDescription(bookmark); + else + skipUnknownElement(); + } + } + if (bookmark->title.isEmpty()) + bookmark->title = QObject::tr("Unknown title"); +} + +void XbelReader::skipUnknownElement() +{ + Q_ASSERT(isStartElement()); + + while (!atEnd()) { + readNext(); + + if (isEndElement()) + break; + + if (isStartElement()) + skipUnknownElement(); + } +} + + +XbelWriter::XbelWriter() +{ + setAutoFormatting(true); +} + +bool XbelWriter::write(const QString &fileName, const BookmarkNode *root) +{ + QFile file(fileName); + if (!root || !file.open(QFile::WriteOnly)) + return false; + return write(&file, root); +} + +bool XbelWriter::write(QIODevice *device, const BookmarkNode *root) +{ + setDevice(device); + + writeStartDocument(); + writeDTD(QLatin1String("")); + writeStartElement(QLatin1String("xbel")); + writeAttribute(QLatin1String("version"), QLatin1String("1.0")); + if (root->type() == BookmarkNode::Root) { + for (int i = 0; i < root->children().count(); ++i) + writeItem(root->children().at(i)); + } else { + writeItem(root); + } + + writeEndDocument(); + return true; +} + +void XbelWriter::writeItem(const BookmarkNode *parent) +{ + switch (parent->type()) { + case BookmarkNode::Folder: + writeStartElement(QLatin1String("folder")); + writeAttribute(QLatin1String("folded"), parent->expanded ? QLatin1String("no") : QLatin1String("yes")); + writeTextElement(QLatin1String("title"), parent->title); + for (int i = 0; i < parent->children().count(); ++i) + writeItem(parent->children().at(i)); + writeEndElement(); + break; + case BookmarkNode::Bookmark: + writeStartElement(QLatin1String("bookmark")); + if (!parent->url.isEmpty()) + writeAttribute(QLatin1String("href"), parent->url); + writeTextElement(QLatin1String("title"), parent->title); + if (!parent->desc.isEmpty()) + writeAttribute(QLatin1String("desc"), parent->desc); + writeEndElement(); + break; + case BookmarkNode::Separator: + writeEmptyElement(QLatin1String("separator")); + break; + default: + break; + } +} diff --git a/src/xbel.h b/src/xbel.h new file mode 100644 index 00000000..fdacd1b9 --- /dev/null +++ b/src/xbel.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the demonstration applications of the Qt Toolkit. +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information +** to ensure GNU General Public Licensing requirements will be met: +** http://www.fsf.org/licensing/licenses/info/GPLv2.html and +** http://www.gnu.org/copyleft/gpl.html. In addition, as a special +** exception, Nokia gives you certain additional rights. These rights +** are described in the Nokia Qt GPL Exception version 1.3, included in +** the file GPL_EXCEPTION.txt in this package. +** +** Qt for Windows(R) Licensees +** As a special exception, Nokia, as the sole copyright holder for Qt +** Designer, grants users of the Qt/Eclipse Integration plug-in the +** right for the Qt/Eclipse Integration to link to functionality +** provided by Qt Designer and its related libraries. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef XBEL_H +#define XBEL_H + +#include +#include + +class BookmarkNode +{ +public: + enum Type { + Root, + Folder, + Bookmark, + Separator + }; + + BookmarkNode(Type type = Root, BookmarkNode *parent = 0); + ~BookmarkNode(); + bool operator==(const BookmarkNode &other); + + Type type() const; + void setType(Type type); + QList children() const; + BookmarkNode *parent() const; + + void add(BookmarkNode *child, int offset = -1); + void remove(BookmarkNode *child); + + QString url; + QString title; + QString desc; + bool expanded; + +private: + BookmarkNode *m_parent; + Type m_type; + QList m_children; + +}; + +class XbelReader : public QXmlStreamReader +{ +public: + XbelReader(); + BookmarkNode *read(const QString &fileName); + BookmarkNode *read(QIODevice *device); + +private: + void skipUnknownElement(); + void readXBEL(BookmarkNode *parent); + void readTitle(BookmarkNode *parent); + void readDescription(BookmarkNode *parent); + void readSeparator(BookmarkNode *parent); + void readFolder(BookmarkNode *parent); + void readBookmarkNode(BookmarkNode *parent); +}; + +#include + +class XbelWriter : public QXmlStreamWriter +{ +public: + XbelWriter(); + bool write(const QString &fileName, const BookmarkNode *root); + bool write(QIODevice *device, const BookmarkNode *root); + +private: + void writeItem(const BookmarkNode *parent); +}; + +#endif // XBEL_H + -- cgit v1.2.1 From a01d13f45b6ccd3a64e7a2cf18996d9bf841d4d9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 30 Oct 2008 19:07:58 +0100 Subject: QApplication --> KApplication --- src/browserapplication.cpp | 179 +++++++++++++++++++++++++++------------------ src/browserapplication.h | 70 +++++++----------- src/main.cpp | 11 ++- 3 files changed, 140 insertions(+), 120 deletions(-) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index f904ea1c..60e1d283 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #include "browserapplication.h" @@ -46,51 +29,43 @@ #include "tabwidget.h" #include "webview.h" -#include -#include -#include -#include -#include -#include - -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include DownloadManager *BrowserApplication::s_downloadManager = 0; HistoryManager *BrowserApplication::s_historyManager = 0; NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0; BookmarksManager *BrowserApplication::s_bookmarksManager = 0; -BrowserApplication::BrowserApplication(int &argc, char **argv) - : QApplication(argc, argv) + + +BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &serverName) + : KApplication() , m_localServer(0) { - QCoreApplication::setOrganizationName(QLatin1String("Trolltech")); - QCoreApplication::setApplicationName(QLatin1String("demobrowser")); - QCoreApplication::setApplicationVersion(QLatin1String("0.1")); -#ifdef Q_WS_QWS - // Use a different server name for QWS so we can run an X11 - // browser and a QWS browser in parallel on the same machine for - // debugging - QString serverName = QCoreApplication::applicationName() + QLatin1String("_qws"); -#else - QString serverName = QCoreApplication::applicationName(); -#endif QLocalSocket socket; socket.connectToServer(serverName); if (socket.waitForConnected(500)) { QTextStream stream(&socket); - QStringList args = QCoreApplication::arguments(); - if (args.count() > 1) - stream << args.last(); + int n = args->count(); + if (n > 1) + stream << args->arg(n-1); else stream << QString(); stream.flush(); @@ -99,9 +74,9 @@ BrowserApplication::BrowserApplication(int &argc, char **argv) } #if defined(Q_WS_MAC) - QApplication::setQuitOnLastWindowClosed(false); + KApplication::setQuitOnLastWindowClosed(false); #else - QApplication::setQuitOnLastWindowClosed(true); + KApplication::setQuitOnLastWindowClosed(true); #endif m_localServer = new QLocalServer(this); @@ -133,6 +108,9 @@ BrowserApplication::BrowserApplication(int &argc, char **argv) QTimer::singleShot(0, this, SLOT(postLaunch())); } + + + BrowserApplication::~BrowserApplication() { delete s_downloadManager; @@ -141,6 +119,8 @@ BrowserApplication::~BrowserApplication() delete s_bookmarksManager; } + + #if defined(Q_WS_MAC) void BrowserApplication::lastWindowClosed() { @@ -151,11 +131,15 @@ void BrowserApplication::lastWindowClosed() } #endif + + BrowserApplication *BrowserApplication::instance() { return (static_cast(QCoreApplication::instance())); } + + #if defined(Q_WS_MAC) #include void BrowserApplication::quitBrowser() @@ -180,6 +164,9 @@ void BrowserApplication::quitBrowser() } #endif + + + /*! Any actions that can be delayed until the window is visible */ @@ -196,15 +183,18 @@ void BrowserApplication::postLaunch() // newMainWindow() needs to be called in main() for this to happen if (m_mainWindows.count() > 0) { - QStringList args = QCoreApplication::arguments(); - if (args.count() > 1) - mainWindow()->loadPage(args.last()); + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + int n = args->count(); + if (n > 1) + mainWindow()->loadPage(args->arg(n-1)); else mainWindow()->slotHome(); } BrowserApplication::historyManager(); } + + void BrowserApplication::loadSettings() { QSettings settings; @@ -234,6 +224,9 @@ void BrowserApplication::loadSettings() settings.endGroup(); } + + + QList BrowserApplication::mainWindows() { clean(); @@ -243,6 +236,9 @@ QList BrowserApplication::mainWindows() return list; } + + + void BrowserApplication::clean() { // cleanup any deleted main windows first @@ -251,6 +247,9 @@ void BrowserApplication::clean() m_mainWindows.removeAt(i); } + + + void BrowserApplication::saveSession() { QWebSettings *globalSettings = QWebSettings::globalSettings(); @@ -274,11 +273,17 @@ void BrowserApplication::saveSession() settings.endGroup(); } + + + bool BrowserApplication::canRestoreSession() const { return !m_lastSession.isEmpty(); } + + + void BrowserApplication::restoreLastSession() { QList windows; @@ -305,16 +310,20 @@ void BrowserApplication::restoreLastSession() } } + + bool BrowserApplication::isTheOnlyBrowser() const { return (m_localServer != 0); } + + void BrowserApplication::installTranslator(const QString &name) { QTranslator *translator = new QTranslator(this); translator->load(name, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - QApplication::installTranslator(translator); + KApplication::installTranslator(translator); } #if defined(Q_WS_MAC) @@ -339,15 +348,19 @@ bool BrowserApplication::event(QEvent* event) default: break; } - return QApplication::event(event); + return KApplication::event(event); } #endif + + void BrowserApplication::openUrl(const QUrl &url) { mainWindow()->loadPage(url.toString()); } + + BrowserMainWindow *BrowserApplication::newMainWindow() { BrowserMainWindow *browser = new BrowserMainWindow(); @@ -356,6 +369,9 @@ BrowserMainWindow *BrowserApplication::newMainWindow() return browser; } + + + BrowserMainWindow *BrowserApplication::mainWindow() { clean(); @@ -364,6 +380,9 @@ BrowserMainWindow *BrowserApplication::mainWindow() return m_mainWindows[0]; } + + + void BrowserApplication::newLocalSocketConnection() { QLocalSocket *socket = m_localServer->nextPendingConnection(); @@ -389,11 +408,16 @@ void BrowserApplication::newLocalSocketConnection() mainWindow()->activateWindow(); } + + CookieJar *BrowserApplication::cookieJar() { return (CookieJar*)networkAccessManager()->cookieJar(); } + + + DownloadManager *BrowserApplication::downloadManager() { if (!s_downloadManager) { @@ -402,6 +426,8 @@ DownloadManager *BrowserApplication::downloadManager() return s_downloadManager; } + + NetworkAccessManager *BrowserApplication::networkAccessManager() { if (!s_networkAccessManager) { @@ -411,6 +437,8 @@ NetworkAccessManager *BrowserApplication::networkAccessManager() return s_networkAccessManager; } + + HistoryManager *BrowserApplication::historyManager() { if (!s_historyManager) { @@ -420,6 +448,9 @@ HistoryManager *BrowserApplication::historyManager() return s_historyManager; } + + + BookmarksManager *BrowserApplication::bookmarksManager() { if (!s_bookmarksManager) { @@ -428,6 +459,8 @@ BookmarksManager *BrowserApplication::bookmarksManager() return s_bookmarksManager; } + + QIcon BrowserApplication::icon(const QUrl &url) const { QIcon icon = QWebSettings::iconForUrl(url); diff --git a/src/browserapplication.h b/src/browserapplication.h index 19d02a47..73b908ce 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -1,49 +1,32 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #ifndef BROWSERAPPLICATION_H #define BROWSERAPPLICATION_H -#include - -#include -#include +#include +#include -#include +#include +#include +#include QT_BEGIN_NAMESPACE class QLocalServer; @@ -55,12 +38,13 @@ class CookieJar; class DownloadManager; class HistoryManager; class NetworkAccessManager; -class BrowserApplication : public QApplication + +class BrowserApplication : public KApplication { Q_OBJECT public: - BrowserApplication(int &argc, char **argv); + BrowserApplication(KCmdLineArgs*, const QString &); ~BrowserApplication(); static BrowserApplication *instance(); void loadSettings(); diff --git a/src/main.cpp b/src/main.cpp index ae4c2173..badfd296 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,11 +18,13 @@  * ============================================================ */ +#include "browserapplication.h" + #include #include -#include "browserapplication.h" +// really simple writing main files today.. int main(int argc, char **argv) { KAboutData aboutData( @@ -42,13 +44,14 @@ int main(int argc, char **argv) aboutData.setProgramIconName("application-internet"); KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineOptions options; - - //TODO make this work options.add("+URL", ki18n("Location to open")); KCmdLineArgs::addCmdLineOptions( options ); - BrowserApplication app(argc, argv); + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + BrowserApplication app(args, "reKonq"); if (!app.isTheOnlyBrowser()) return 0; app.newMainWindow(); -- cgit v1.2.1 From a86522cb83ed2f665161f507531f07dc6437e13f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 31 Oct 2008 17:30:37 +0100 Subject: Various improvements on the street from Qt demo browser to KDE reKonq! - CMakeLists.txt working - data dirs - ... --- data/CMakeLists.txt | 5 + data/browser.svg | 1598 +++++++++++++++++++++++++++++++++++++++++++ data/defaultbookmarks.xbel | 40 ++ data/loading.gif | Bin 0 -> 847 bytes htmls/CMakeLists.txt | 4 + htmls/notfound.html | 63 ++ icons/CMakeLists.txt | 1 + icons/hi-64-apps-rekonq.png | Bin 0 -> 5650 bytes src/searchbar.cpp | 477 +++++++++++++ src/searchbar.h | 104 +++ 10 files changed, 2292 insertions(+) create mode 100644 data/CMakeLists.txt create mode 100644 data/browser.svg create mode 100644 data/defaultbookmarks.xbel create mode 100644 data/loading.gif create mode 100644 htmls/CMakeLists.txt create mode 100644 htmls/notfound.html create mode 100644 icons/CMakeLists.txt create mode 100644 icons/hi-64-apps-rekonq.png create mode 100644 src/searchbar.cpp create mode 100644 src/searchbar.h diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt new file mode 100644 index 00000000..2882b681 --- /dev/null +++ b/data/CMakeLists.txt @@ -0,0 +1,5 @@ +INSTALL( FILES + defaultbookmarks.xbel + loading.gif + DESTINATION ${DATA_INSTALL_DIR}/rekonq/pics +) diff --git a/data/browser.svg b/data/browser.svg new file mode 100644 index 00000000..c42af2bc --- /dev/null +++ b/data/browser.svg @@ -0,0 +1,1598 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/defaultbookmarks.xbel b/data/defaultbookmarks.xbel new file mode 100644 index 00000000..f1c9253d --- /dev/null +++ b/data/defaultbookmarks.xbel @@ -0,0 +1,40 @@ + + + + + Bookmarks Bar + + Trolltech.com + + + WebKit.org + + + Qt Documentation + + + Qt Quarterly + + + Trolltech Labs + + + Qt Centre + + + Qt-Apps.org + + + qtnode + + + xkcd + + + + Bookmarks Menu + + reddit.com: what's new online! + + + diff --git a/data/loading.gif b/data/loading.gif new file mode 100644 index 00000000..c1545eb0 Binary files /dev/null and b/data/loading.gif differ diff --git a/htmls/CMakeLists.txt b/htmls/CMakeLists.txt new file mode 100644 index 00000000..5b35db92 --- /dev/null +++ b/htmls/CMakeLists.txt @@ -0,0 +1,4 @@ +INSTALL( FILES + notfound.html + DESTINATION ${DATA_INSTALL_DIR}/rekonq/htmls +) diff --git a/htmls/notfound.html b/htmls/notfound.html new file mode 100644 index 00000000..77994119 --- /dev/null +++ b/htmls/notfound.html @@ -0,0 +1,63 @@ + + +%1 + + + +
+ +

%2

+

When connecting to: %3.

+
    +
  • Check the address for errors such as ww.kde.org + instead of www.kde.org
  • +
  • If the address is correct, try to check the network + connection.
  • +
  • If your computer or network is protected by a firewall or + proxy, make sure that the browser demo is permitted to access + the network.
  • +
+

+
+ + diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt new file mode 100644 index 00000000..5d6766e8 --- /dev/null +++ b/icons/CMakeLists.txt @@ -0,0 +1 @@ +KDE4_INSTALL_ICONS( ${ICON_INSTALL_DIR} ) diff --git a/icons/hi-64-apps-rekonq.png b/icons/hi-64-apps-rekonq.png new file mode 100644 index 00000000..312b572a Binary files /dev/null and b/icons/hi-64-apps-rekonq.png differ diff --git a/src/searchbar.cpp b/src/searchbar.cpp new file mode 100644 index 00000000..f1f6ef80 --- /dev/null +++ b/src/searchbar.cpp @@ -0,0 +1,477 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#include "searchbar.h" + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + + + +SearchBar::SearchBar() : + m_searchCombo(0), + m_searchMode(UseSearchProvider), + m_urlEnterLock(false), + m_process(0) +{ + m_searchCombo = new SearchBarCombo(0); + m_searchCombo->lineEdit()->installEventFilter(this); + connect(m_searchCombo, SIGNAL(activated(const QString &)), SLOT(startSearch(const QString &))); + connect(m_searchCombo, SIGNAL(iconClicked()), SLOT(showSelectionMenu())); + m_searchCombo->setWhatsThis(i18n("Search Bar

" + "Enter a search term. Click on the icon to change search mode or provider.

")); + + m_popupMenu = 0; + + m_searchComboAction = actionCollection()->addAction("toolbar_search_bar"); + m_searchComboAction->setText(i18n("Search Bar")); + m_searchComboAction->setDefaultWidget(m_searchCombo); + m_searchComboAction->setShortcutConfigurable(false); + + + KAction *a = actionCollection()->addAction("focus_search_bar"); + a->setText(i18n("Focus Searchbar")); + a->setShortcut(Qt::CTRL+Qt::Key_S); + connect(a, SIGNAL(triggered()), this, SLOT(focusSearchbar())); + + configurationChanged(); + + // parent is the KonqMainWindow and we want to listen to PartActivateEvent events. + parent->installEventFilter(this); +} + + + +SearchBar::~SearchBar() +{ + KConfigGroup config(KGlobal::config(), "SearchBar"); + config.writeEntry("Mode", (int) m_searchMode); + config.writeEntry("CurrentEngine", m_currentEngine); + + delete m_searchCombo; + m_searchCombo = 0L; + delete m_process; + m_process=0L; +} + +static QChar delimiter() +{ + static QChar s_delimiter = 0; + if (s_delimiter == 0) { + KConfig _config("kuriikwsfilterrc", KConfig::NoGlobals); + KConfigGroup config(&_config, "General"); + s_delimiter = config.readEntry("KeywordDelimiter", int(':')); + } + return s_delimiter; +} + + + +void SearchBar::nextSearchEntry() +{ + if (m_searchMode == FindInThisPage) { + m_searchMode = UseSearchProvider; + if (!m_searchEngines.isEmpty()) { + m_currentEngine = m_searchEngines.first(); + } else { + m_currentEngine = "google"; + } + } else { + int index = m_searchEngines.indexOf(m_currentEngine); + ++index; + if (index >= m_searchEngines.count()) { + m_searchMode = FindInThisPage; + } else { + m_currentEngine = m_searchEngines.at(index); + } + } + setIcon(); +} + +void SearchBar::previousSearchEntry() +{ + if (m_searchMode == FindInThisPage) { + m_searchMode = UseSearchProvider; + if (!m_searchEngines.isEmpty()) { + m_currentEngine = m_searchEngines.last(); + } else { + m_currentEngine = "google"; + } + } else { + int index = m_searchEngines.indexOf(m_currentEngine); + if (index == 0) { + m_searchMode = FindInThisPage; + } else { + --index; + m_currentEngine = m_searchEngines.at(index); + } + } + setIcon(); +} + +void SearchBar::startSearch(const QString &search) +{ + if ( m_urlEnterLock || search.isEmpty() ) + return; + if (m_searchMode == UseSearchProvider) { + m_urlEnterLock = true; + KService::Ptr service; + KUriFilterData data; + QStringList list; + list << "kurisearchfilter" << "kuriikwsfilter"; + + service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine)); + if (service) { + const QString searchProviderPrefix = service->property("Keys").toStringList().first() + delimiter(); + data.setData(searchProviderPrefix + search); + } + + if (!service || !KUriFilter::self()->filterUri(data, list)) { + data.setData(QLatin1String("google") + delimiter() + search); + KUriFilter::self()->filterUri(data, list); + } + + if (QApplication::keyboardModifiers() & Qt::ControlModifier) { + KParts::OpenUrlArguments arguments; + KParts::BrowserArguments browserArguments; + browserArguments.setNewTab(true); + if (ext) + emit ext->createNewWindow(data.uri(), arguments, browserArguments); + } else { + if (ext) { + emit ext->openUrlRequest(data.uri()); + m_part->widget()->setFocus(); // #152923 + } + } + } + + m_searchCombo->addToHistory(search); + m_searchCombo->setItemIcon(0, m_searchIcon); + + m_urlEnterLock = false; +} + +void SearchBarPlugin::setIcon() +{ + if (m_searchMode == FindInThisPage) { + m_searchIcon = SmallIcon("edit-find"); + } else { + KService::Ptr service; + KUriFilterData data; + QStringList list; + list << "kurisearchfilter" << "kuriikwsfilter"; + + service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine)); + if (service) { + const QString searchProviderPrefix = service->property("Keys").toStringList().first() + delimiter(); + data.setData(searchProviderPrefix + "some keyword"); + } + + if (service && KUriFilter::self()->filterUri(data, list)) + { + QString iconPath = KStandardDirs::locate("cache", KMimeType::favIconForUrl(data.uri()) + ".png"); + if (iconPath.isEmpty()) { + m_searchIcon = SmallIcon("unknown"); + } else { + m_searchIcon = QPixmap(iconPath); + } + } + else + { + m_searchIcon = SmallIcon("google"); + } + } + + // Create a bit wider icon with arrow + QPixmap arrowmap = QPixmap(m_searchIcon.width()+5,m_searchIcon.height()+5); + arrowmap.fill(m_searchCombo->lineEdit()->palette().color(m_searchCombo->lineEdit()->backgroundRole())); + QPainter p(&arrowmap); + p.drawPixmap(0, 2, m_searchIcon); + QStyleOption opt; + opt.state = QStyle::State_None; + opt.rect = QRect(arrowmap.width()-6, arrowmap.height()-5, 6, 5); + m_searchCombo->style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &opt, &p, m_searchCombo); + p.end(); + m_searchIcon = arrowmap; + + m_searchCombo->setIcon(m_searchIcon); +} + +void SearchBar::showSelectionMenu() +{ + if (!m_popupMenu) { + KUriFilterData data; + QStringList list; + list << "kurisearchfilter" << "kuriikwsfilter"; + + m_popupMenu = new QMenu(m_searchCombo); + m_popupMenu->setObjectName("search selection menu"); + m_popupMenu->addAction(KIcon("edit-find"), i18n("Find in This Page"), this, SLOT(useFindInThisPage())); + m_popupMenu->addSeparator(); + + int i=-1; + for (QStringList::ConstIterator it = m_searchEngines.begin(); it != m_searchEngines.end(); ++it) { + i++; + KService::Ptr service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(*it)); + if (!service) { + continue; + } + const QString searchProviderPrefix = service->property("Keys").toStringList().first() + delimiter(); + data.setData(searchProviderPrefix + "some keyword"); + + if (KUriFilter::self()->filterUri(data, list)) + { + QIcon icon; + QString iconPath = KStandardDirs::locate("cache", KMimeType::favIconForUrl(data.uri()) + ".png"); + if (iconPath.isEmpty()) { + icon = KIcon("unknown"); + } else { + icon = QPixmap(iconPath); + } + QAction* action = m_popupMenu->addAction(icon, service->name()); + action->setData(qVariantFromValue(i)); + } + } + + m_popupMenu->addSeparator(); + m_popupMenu->addAction(KIcon("preferences-web-browser-shortcuts"), i18n("Select Search Engines..."), + this, SLOT(selectSearchEngines())); + connect(m_popupMenu, SIGNAL(triggered(QAction *)), SLOT(useSearchProvider(QAction *))); + } + m_popupMenu->popup(m_searchCombo->mapToGlobal(QPoint(0, m_searchCombo->height() + 1))); +} + +void SearchBar::useFindInThisPage() +{ + m_searchMode = FindInThisPage; + setIcon(); +} + +void SearchBar::useSearchProvider(QAction *action) +{ + bool ok = false; + const int id = action->data().toInt(&ok); + if(!ok) { + // Not a search engine entry selected + return; + } + m_searchMode = UseSearchProvider; + m_currentEngine = m_searchEngines.at(id); + setIcon(); + m_searchCombo->lineEdit()->selectAll(); +} + +void SearchBar::selectSearchEngines() +{ + m_process = new KProcess; + + *m_process << "kcmshell4" << "ebrowsing"; + + connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(searchEnginesSelected(int,QProcess::ExitStatus))); + + m_process->start(); + if(!m_process->waitForStarted()) + { + kDebug(1202) << "Couldn't invoke kcmshell"; + delete m_process; + m_process = 0; + } +} + +void SearchBar::searchEnginesSelected(int exitCode, QProcess::ExitStatus exitStatus) +{ + Q_UNUSED(exitCode); + if(exitStatus == QProcess::NormalExit) { + KConfigGroup config(KGlobal::config(), "SearchBar"); + config.writeEntry("CurrentEngine", m_currentEngine); + config.sync(); + configurationChanged(); + } + delete m_process; + m_process = 0; +} + +void SearchBar::configurationChanged() +{ + KConfigGroup config(KSharedConfig::openConfig("kuriikwsfilterrc"), "General"); + const QString engine = config.readEntry("DefaultSearchEngine", "google"); + + QStringList favoriteEngines; + favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia"; + favoriteEngines = config.readEntry("FavoriteSearchEngines", favoriteEngines); + + delete m_popupMenu; + m_popupMenu = 0; + m_searchEngines.clear(); + m_searchEngines << engine; + for (QStringList::ConstIterator it = favoriteEngines.begin(); it != favoriteEngines.end(); ++it) + if(*it!=engine) + m_searchEngines << *it; + + if(engine.isEmpty()) { + m_providerName = "Google"; + } else { + KDesktopFile file("services", "searchproviders/" + engine + ".desktop"); + m_providerName = file.readName(); + } + + config = KConfigGroup(KGlobal::config(), "SearchBar"); + m_searchMode = (SearchModes) config.readEntry("Mode", (int) UseSearchProvider); + m_currentEngine = config.readEntry("CurrentEngine", engine); + + if (m_currentEngine.isEmpty()) + m_currentEngine = "google"; + + setIcon(); +} + + + +void SearchBar::updateComboVisibility() +{ + if (!m_part|| m_searchComboAction->associatedWidgets().isEmpty()) + { + m_searchCombo->setPluginActive(false); + m_searchCombo->hide(); + } else { + m_searchCombo->setPluginActive(true); + m_searchCombo->show(); + } +} + + + +void SearchBar::focusSearchbar() +{ + m_searchCombo->setFocus(Qt::ShortcutFocusReason); +} + + + +SearchBarCombo::SearchBarCombo(QWidget *parent) : + KHistoryComboBox(parent), + m_pluginActive(true) +{ + setDuplicatesEnabled(false); + setFixedWidth(180); + connect(this, SIGNAL(cleared()), SLOT(historyCleared())); + + Q_ASSERT(useCompletion()); + + KConfigGroup config(KGlobal::config(), "SearchBar"); + QStringList list = config.readEntry( "History list", QStringList() ); + list.prepend(QString()); // empty item + setHistoryItems(list, true); + Q_ASSERT(currentText().isEmpty()); // KHistoryComboBox calls clearEditText +} + +const QPixmap &SearchBarCombo::icon() const +{ + return m_icon; +} + +void SearchBarCombo::setIcon(const QPixmap &icon) +{ + m_icon = icon; + const QString editText = currentText(); + if (count() == 0) { + insertItem(0, m_icon, 0); + } else { + for(int i = 0; i < count(); i++) { + setItemIcon(i, m_icon); + } + } + setEditText(editText); +} + +int SearchBarCombo::findHistoryItem(const QString &searchText) +{ + for(int i = 0; i < count(); i++) { + if (itemText(i) == searchText) { + return i; + } + } + + return -1; +} + +void SearchBarCombo::mousePressEvent(QMouseEvent *e) +{ + QStyleOptionComplex opt; + int x0 = QStyle::visualRect(layoutDirection(), style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxEditField, this), rect()).x(); + + if (e->x() > x0 + 2 && e->x() < lineEdit()->x()) { + emit iconClicked(); + + e->accept(); + } else { + KHistoryComboBox::mousePressEvent(e); + } +} + +void SearchBarCombo::historyCleared() +{ + setIcon(m_icon); +} + +void SearchBarCombo::setPluginActive(bool pluginActive) +{ + m_pluginActive = pluginActive; +} + +void SearchBarCombo::show() +{ + if (m_pluginActive) { + KHistoryComboBox::show(); + } +} + +SearchBarCombo::~SearchBarCombo() +{ + KConfigGroup config(KGlobal::config(), "SearchBar"); + config.writeEntry( "History list", historyItems() ); +} + +#include "searchbar.moc" diff --git a/src/searchbar.h b/src/searchbar.h new file mode 100644 index 00000000..222b97e4 --- /dev/null +++ b/src/searchbar.h @@ -0,0 +1,104 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef SEARCHBAR_H +#define SEARCHBAR_H + +#include +#include +#include +#include + +#include +#include +#include + +class KHTMLPart; + + +class SearchBarCombo : public KHistoryComboBox +{ + Q_OBJECT + +public: + SearchBarCombo(QWidget *parent); + ~SearchBarCombo(); + const QPixmap &icon() const; + void setIcon(const QPixmap &icon); + int findHistoryItem(const QString &text); + +public slots: + virtual void show(); + +signals: + void iconClicked(); + +protected: + virtual void mousePressEvent(QMouseEvent *e); + +private slots: + void historyCleared(); + +private: + QPixmap m_icon; +}; + + +class SearchBar : public KDialog +{ + Q_OBJECT + +public: + enum SearchModes { FindInThisPage = 0, UseSearchProvider }; + + SearchBar(); + virtual ~SearchBar(); + +private slots: + void startSearch(const QString &search); + void setIcon(); + void showSelectionMenu(); + + void useFindInThisPage(); + void useSearchProvider(QAction *); + void selectSearchEngines(); + void searchEnginesSelected(int, QProcess::ExitStatus); + void configurationChanged(); + + void updateComboVisibility(); + + void focusSearchbar(); +private: + void nextSearchEntry(); + void previousSearchEntry(); + + + SearchBarCombo *m_searchCombo; + KAction *m_searchComboAction; + QMenu *m_popupMenu; + QPixmap m_searchIcon; + SearchModes m_searchMode; + QString m_providerName; + bool m_urlEnterLock; + QString m_currentEngine; + QStringList m_searchEngines; + KProcess *m_process; +}; + +#endif -- cgit v1.2.1 From 2147abb0c02358b512925191d3e545574ec80e08 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 1 Nov 2008 13:04:26 +0100 Subject: Localizing strings.. --- CMakeLists.txt | 3 + src/CMakeLists.txt | 2 +- src/bookmarks.cpp | 162 ++-- src/browserapplication.cpp | 14 +- src/browserapplication.h | 6 +- src/browsermainwindow.cpp | 559 +++++++------- src/browsermainwindow.h | 83 +-- src/chasewidget.cpp | 138 ---- src/chasewidget.h | 81 -- src/cookiejar.cpp | 115 ++- src/data/addtab.png | Bin 469 -> 0 bytes src/data/browser.svg | 1598 ---------------------------------------- src/data/closetab.png | Bin 516 -> 0 bytes src/data/data.qrc | 11 - src/data/defaultbookmarks.xbel | 40 - src/data/defaulticon.png | Bin 1473 -> 0 bytes src/data/history.png | Bin 1527 -> 0 bytes src/data/loading.gif | Bin 847 -> 0 bytes src/downloadmanager.cpp | 130 ++-- src/downloadmanager.h | 61 +- src/history.cpp | 127 ++-- src/history.h | 71 +- src/htmls/htmls.qrc | 5 - src/htmls/notfound.html | 63 -- src/main.cpp | 2 +- src/networkaccessmanager.cpp | 88 +-- src/networkaccessmanager.h | 54 +- src/searchlineedit.cpp | 71 +- src/searchlineedit.h | 60 +- src/tabwidget.cpp | 104 ++- src/tabwidget.h | 56 +- src/toolbarsearch.cpp | 82 +-- src/toolbarsearch.h | 54 +- src/webview.cpp | 80 +- src/webview.h | 56 +- src/xbel.cpp | 67 +- src/xbel.h | 54 +- 37 files changed, 928 insertions(+), 3169 deletions(-) delete mode 100644 src/chasewidget.cpp delete mode 100644 src/chasewidget.h delete mode 100644 src/data/addtab.png delete mode 100644 src/data/browser.svg delete mode 100644 src/data/closetab.png delete mode 100644 src/data/data.qrc delete mode 100644 src/data/defaultbookmarks.xbel delete mode 100644 src/data/defaulticon.png delete mode 100644 src/data/history.png delete mode 100644 src/data/loading.gif delete mode 100644 src/htmls/htmls.qrc delete mode 100755 src/htmls/notfound.html diff --git a/CMakeLists.txt b/CMakeLists.txt index 78d320d6..f4de5473 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,3 +20,6 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ) ADD_SUBDIRECTORY( src ) +ADD_SUBDIRECTORY( icons ) +ADD_SUBDIRECTORY( data ) +ADD_SUBDIRECTORY( htmls ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 26283c2e..d10368f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,6 @@ SET( rekonq_SRCS bookmarks.cpp browserapplication.cpp browsermainwindow.cpp - chasewidget.cpp cookiejar.cpp downloadmanager.cpp edittableview.cpp @@ -12,6 +11,7 @@ SET( rekonq_SRCS modelmenu.cpp networkaccessmanager.cpp searchlineedit.cpp +# searchbar.cpp settings.cpp squeezelabel.cpp tabwidget.cpp diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 9b47747d..7f432ba9 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -1,62 +1,44 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes #include "bookmarks.h" - #include "autosaver.h" #include "browserapplication.h" #include "history.h" #include "xbel.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include +// Qt Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include #define BOOKMARKBAR "Bookmarks Bar" #define BOOKMARKMENU "Bookmarks Menu" @@ -101,8 +83,13 @@ void BookmarksManager::load() m_bookmarkRootNode = reader.read(bookmarkFile); if (reader.error() != QXmlStreamReader::NoError) { QMessageBox::warning(0, QLatin1String("Loading Bookmark"), - tr("Error when loading bookmarks on line %1, column %2:\n" - "%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString())); + i18n("Error when loading bookmarks on line ") + + QString( (int) reader.lineNumber() ) + + i18n(", column ") + + QString( (int) reader.columnNumber() ) + + ":\n" + + reader.errorString() + ) ; } BookmarkNode *toolbar = 0; @@ -112,18 +99,18 @@ void BookmarksManager::load() BookmarkNode *node = m_bookmarkRootNode->children().at(i); if (node->type() == BookmarkNode::Folder) { // Automatically convert - if (node->title == tr("Toolbar Bookmarks") && !toolbar) { - node->title = tr(BOOKMARKBAR); + if (node->title == i18n("Toolbar Bookmarks") && !toolbar) { + node->title = i18n(BOOKMARKBAR); } - if (node->title == tr(BOOKMARKBAR) && !toolbar) { + if (node->title == i18n(BOOKMARKBAR) && !toolbar) { toolbar = node; } // Automatically convert - if (node->title == tr("Menu") && !menu) { - node->title = tr(BOOKMARKMENU); + if (node->title == i18n("Menu") && !menu) { + node->title = i18n(BOOKMARKMENU); } - if (node->title == tr(BOOKMARKMENU) && !menu) { + if (node->title == i18n(BOOKMARKMENU) && !menu) { menu = node; } } else { @@ -134,14 +121,14 @@ void BookmarksManager::load() Q_ASSERT(m_bookmarkRootNode->children().count() == 0); if (!toolbar) { toolbar = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); - toolbar->title = tr(BOOKMARKBAR); + toolbar->title = i18n(BOOKMARKBAR); } else { m_bookmarkRootNode->add(toolbar); } if (!menu) { menu = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); - menu->title = tr(BOOKMARKMENU); + menu->title = i18n(BOOKMARKMENU); } else { m_bookmarkRootNode->add(menu); } @@ -217,7 +204,7 @@ BookmarkNode *BookmarksManager::menu() for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { BookmarkNode *node = m_bookmarkRootNode->children().at(i); - if (node->title == tr(BOOKMARKMENU)) + if (node->title == i18n(BOOKMARKMENU)) return node; } Q_ASSERT(false); @@ -231,7 +218,7 @@ BookmarkNode *BookmarksManager::toolbar() for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { BookmarkNode *node = m_bookmarkRootNode->children().at(i); - if (node->title == tr(BOOKMARKBAR)) + if (node->title == i18n(BOOKMARKBAR)) return node; } Q_ASSERT(false); @@ -247,9 +234,9 @@ BookmarksModel *BookmarksManager::bookmarksModel() void BookmarksManager::importBookmarks() { - QString fileName = QFileDialog::getOpenFileName(0, tr("Open File"), + QString fileName = QFileDialog::getOpenFileName(0, i18n("Open File"), QString(), - tr("XBEL (*.xbel *.xml)")); + i18n("XBEL (*.xbel *.xml)")); if (fileName.isEmpty()) return; @@ -257,30 +244,30 @@ void BookmarksManager::importBookmarks() BookmarkNode *importRootNode = reader.read(fileName); if (reader.error() != QXmlStreamReader::NoError) { QMessageBox::warning(0, QLatin1String("Loading Bookmark"), - tr("Error when loading bookmarks on line %1, column %2:\n" - "%3").arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.errorString())); + i18n("Error when loading bookmarks on line %1, column %2:\n %3", reader.lineNumber(), reader.columnNumber(), reader.errorString() ) + ); } importRootNode->setType(BookmarkNode::Folder); - importRootNode->title = (tr("Imported %1").arg(QDate::currentDate().toString(Qt::SystemLocaleShortDate))); + importRootNode->title = ( i18n("Imported ") + QDate::currentDate().toString(Qt::SystemLocaleShortDate) ); addBookmark(menu(), importRootNode); } void BookmarksManager::exportBookmarks() { - QString fileName = QFileDialog::getSaveFileName(0, tr("Save File"), - tr("%1 Bookmarks.xbel").arg(QCoreApplication::applicationName()), - tr("XBEL (*.xbel *.xml)")); + QString fileName = QFileDialog::getSaveFileName(0, i18n("Save File"), + QCoreApplication::applicationName() + i18n(" Bookmarks.xbel"), + i18n("XBEL (*.xbel *.xml)")); if (fileName.isEmpty()) return; XbelWriter writer; if (!writer.write(fileName, m_bookmarkRootNode)) - QMessageBox::critical(0, tr("Export error"), tr("error saving bookmarks")); + QMessageBox::critical(0, i18n("Export error"), i18n("error saving bookmarks")); } RemoveBookmarksCommand::RemoveBookmarksCommand(BookmarksManager *m_bookmarkManagaer, BookmarkNode *parent, int row) - : QUndoCommand(BookmarksManager::tr("Remove Bookmark")) + : QUndoCommand( i18n("Remove Bookmark") ) , m_row(row) , m_bookmarkManagaer(m_bookmarkManagaer) , m_node(parent->children().value(row)) @@ -314,7 +301,7 @@ InsertBookmarksCommand::InsertBookmarksCommand(BookmarksManager *m_bookmarkManag BookmarkNode *parent, BookmarkNode *node, int row) : RemoveBookmarksCommand(m_bookmarkManagaer, parent, row) { - setText(BookmarksManager::tr("Insert Bookmark")); + setText( i18n("Insert Bookmark") ); m_node = node; } @@ -328,10 +315,10 @@ ChangeBookmarkCommand::ChangeBookmarkCommand(BookmarksManager *m_bookmarkManagae { if (m_title) { m_oldValue = m_node->title; - setText(BookmarksManager::tr("Name Change")); + setText( i18n("Name Change") ); } else { m_oldValue = m_node->url; - setText(BookmarksManager::tr("Address Change")); + setText( i18n("Address Change") ); } } @@ -358,12 +345,9 @@ BookmarksModel::BookmarksModel(BookmarksManager *bookmarkManager, QObject *paren , m_endMacro(false) , m_bookmarksManager(bookmarkManager) { - connect(bookmarkManager, SIGNAL(entryAdded(BookmarkNode *)), - this, SLOT(entryAdded(BookmarkNode *))); - connect(bookmarkManager, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), - this, SLOT(entryRemoved(BookmarkNode *, int, BookmarkNode *))); - connect(bookmarkManager, SIGNAL(entryChanged(BookmarkNode *)), - this, SLOT(entryChanged(BookmarkNode *))); + connect(bookmarkManager, SIGNAL(entryAdded(BookmarkNode *)), this, SLOT(entryAdded(BookmarkNode *))); + connect(bookmarkManager, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), this, SLOT(entryRemoved(BookmarkNode *, int, BookmarkNode *))); + connect(bookmarkManager, SIGNAL(entryChanged(BookmarkNode *)), this, SLOT(entryChanged(BookmarkNode *))); } QModelIndex BookmarksModel::index(BookmarkNode *node) const @@ -426,8 +410,8 @@ QVariant BookmarksModel::headerData(int section, Qt::Orientation orientation, in { if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { - case 0: return tr("Title"); - case 1: return tr("Address"); + case 0: return i18n("Title"); + case 1: return i18n("Address"); } } return QAbstractItemModel::headerData(section, orientation, role); @@ -843,10 +827,10 @@ void BookmarksDialog::customContextMenuRequested(const QPoint &pos) QModelIndex index = tree->indexAt(pos); index = index.sibling(index.row(), 0); if (index.isValid() && !tree->model()->hasChildren(index)) { - menu.addAction(tr("Open"), this, SLOT(open())); + menu.addAction( i18n("Open"), this, SLOT(open())); menu.addSeparator(); } - menu.addAction(tr("Delete"), tree, SLOT(removeOne())); + menu.addAction( i18n("Delete"), tree, SLOT(removeOne())); menu.exec(QCursor::pos()); } @@ -869,12 +853,12 @@ void BookmarksDialog::newFolder() idx = m_proxyModel->mapToSource(idx); BookmarkNode *parent = m_bookmarksManager->bookmarksModel()->node(idx); BookmarkNode *node = new BookmarkNode(BookmarkNode::Folder); - node->title = tr("New Folder"); + node->title = i18n("New Folder"); m_bookmarksManager->addBookmark(parent, node, currentIndex.row() + 1); } BookmarksToolBar::BookmarksToolBar(BookmarksModel *model, QWidget *parent) - : QToolBar(tr("Bookmark"), parent) + : QToolBar( i18n("Bookmark"), parent) , m_bookmarksModel(model) { connect(this, SIGNAL(actionTriggered(QAction*)), this, SLOT(triggered(QAction*))); diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 60e1d283..6d4e08fa 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -152,8 +152,7 @@ void BrowserApplication::quitBrowser() if (tabCount > 1) { int ret = QMessageBox::warning(mainWindow(), QString(), - tr("There are %1 windows and %2 tabs open\n" - "Do you want to quit anyway?").arg(m_mainWindows.count()).arg(tabCount), + i18n("There are ") + QString( m_mainWindows.count() ) + i18n(" windows and ") + QString(tabCount) + i18n("tabs open\n"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (ret == QMessageBox::No) @@ -461,12 +460,13 @@ BookmarksManager *BrowserApplication::bookmarksManager() -QIcon BrowserApplication::icon(const QUrl &url) const +KIcon BrowserApplication::icon(const QUrl &url) const { - QIcon icon = QWebSettings::iconForUrl(url); + KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); if (!icon.isNull()) - return icon.pixmap(16, 16); + return icon; if (m_defaultIcon.isNull()) - m_defaultIcon = QIcon(QLatin1String(":defaulticon.png")); - return m_defaultIcon.pixmap(16, 16); + m_defaultIcon = KIcon("rekonq"); + return m_defaultIcon; } + diff --git a/src/browserapplication.h b/src/browserapplication.h index 73b908ce..801cdec5 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -23,10 +23,10 @@ #include #include +#include #include #include -#include QT_BEGIN_NAMESPACE class QLocalServer; @@ -52,7 +52,7 @@ public: bool isTheOnlyBrowser() const; BrowserMainWindow *mainWindow(); QList mainWindows(); - QIcon icon(const QUrl &url) const; + KIcon icon(const QUrl &url) const; void saveSession(); bool canRestoreSession() const; @@ -92,7 +92,7 @@ private: QList > m_mainWindows; QLocalServer *m_localServer; QByteArray m_lastSession; - mutable QIcon m_defaultIcon; + mutable KIcon m_defaultIcon; }; #endif // BROWSERAPPLICATION_H diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 3d1617e4..450f90b5 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -1,46 +1,28 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #include "browsermainwindow.h" #include "autosaver.h" #include "bookmarks.h" #include "browserapplication.h" -#include "chasewidget.h" #include "downloadmanager.h" #include "history.h" #include "settings.h" @@ -49,27 +31,29 @@ #include "ui_passworddialog.h" #include "webview.h" -#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include -#include -#include +#include -#include BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) - : QMainWindow(parent, flags) + : KMainWindow(parent, flags) , m_tabWidget(new TabWidget(this)) , m_autoSaver(new AutoSaver(this)) , m_historyBack(0) @@ -83,57 +67,34 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) setupToolBar(); QWidget *centralWidget = new QWidget(this); - BookmarksModel *boomarksModel = BrowserApplication::bookmarksManager()->bookmarksModel(); - m_bookmarksToolbar = new BookmarksToolBar(boomarksModel, this); - connect(m_bookmarksToolbar, SIGNAL(openUrl(const QUrl&)), - m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); - connect(m_bookmarksToolbar->toggleViewAction(), SIGNAL(toggled(bool)), - this, SLOT(updateBookmarksToolbarActionText(bool))); QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); layout->setMargin(0); #if defined(Q_WS_MAC) - layout->addWidget(m_bookmarksToolbar); layout->addWidget(new QWidget); // <- OS X tab widget style bug #else addToolBarBreak(); - addToolBar(m_bookmarksToolbar); #endif layout->addWidget(m_tabWidget); centralWidget->setLayout(layout); setCentralWidget(centralWidget); - connect(m_tabWidget, SIGNAL(loadPage(const QString &)), - this, SLOT(loadPage(const QString &))); - connect(m_tabWidget, SIGNAL(setCurrentTitle(const QString &)), - this, SLOT(slotUpdateWindowTitle(const QString &))); - connect(m_tabWidget, SIGNAL(showStatusBarMessage(const QString&)), - statusBar(), SLOT(showMessage(const QString&))); - connect(m_tabWidget, SIGNAL(linkHovered(const QString&)), - statusBar(), SLOT(showMessage(const QString&))); - connect(m_tabWidget, SIGNAL(loadProgress(int)), - this, SLOT(slotLoadProgress(int))); - connect(m_tabWidget, SIGNAL(tabsChanged()), - m_autoSaver, SLOT(changeOccurred())); - connect(m_tabWidget, SIGNAL(geometryChangeRequested(const QRect &)), - this, SLOT(geometryChangeRequested(const QRect &))); - connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)), - this, SLOT(printRequested(QWebFrame *))); - connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)), - menuBar(), SLOT(setVisible(bool))); - connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)), - statusBar(), SLOT(setVisible(bool))); - connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), - m_navigationBar, SLOT(setVisible(bool))); - connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), - m_bookmarksToolbar, SLOT(setVisible(bool))); + connect(m_tabWidget, SIGNAL(loadPage(const QString &)), this, SLOT(loadPage(const QString &))); + connect(m_tabWidget, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); + connect(m_tabWidget, SIGNAL(showStatusBarMessage(const QString&)), statusBar(), SLOT(showMessage(const QString&))); + connect(m_tabWidget, SIGNAL(linkHovered(const QString&)), statusBar(), SLOT(showMessage(const QString&))); + connect(m_tabWidget, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); + connect(m_tabWidget, SIGNAL(tabsChanged()), m_autoSaver, SLOT(changeOccurred())); + connect(m_tabWidget, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &))); + connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); + connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); + connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); + connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), m_navigationBar, SLOT(setVisible(bool))); #if defined(Q_WS_MAC) - connect(m_tabWidget, SIGNAL(lastTabClosed()), - this, SLOT(close())); + connect(m_tabWidget, SIGNAL(lastTabClosed()), this, SLOT(close())); #else - connect(m_tabWidget, SIGNAL(lastTabClosed()), - m_tabWidget, SLOT(newTab())); + connect(m_tabWidget, SIGNAL(lastTabClosed()), m_tabWidget, SLOT(newTab())); #endif slotUpdateWindowTitle(); @@ -144,12 +105,16 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) m_navigationBar->setIconSize(QSize(size, size)); } + + BrowserMainWindow::~BrowserMainWindow() { m_autoSaver->changeOccurred(); m_autoSaver->saveIfNeccessary(); } + + void BrowserMainWindow::loadDefaultState() { QSettings settings; @@ -159,6 +124,8 @@ void BrowserMainWindow::loadDefaultState() settings.endGroup(); } + + QSize BrowserMainWindow::sizeHint() const { QRect desktopRect = QApplication::desktop()->screenGeometry(); @@ -166,6 +133,8 @@ QSize BrowserMainWindow::sizeHint() const return size; } + + void BrowserMainWindow::save() { BrowserApplication::instance()->saveSession(); @@ -177,8 +146,12 @@ void BrowserMainWindow::save() settings.endGroup(); } + + static const qint32 BrowserMainWindowMagic = 0xba; + + QByteArray BrowserMainWindow::saveState(bool withTabs) const { int version = 2; @@ -190,8 +163,7 @@ QByteArray BrowserMainWindow::saveState(bool withTabs) const stream << size(); stream << !m_navigationBar->isHidden(); - stream << !m_bookmarksToolbar->isHidden(); - stream << !statusBar()->isHidden(); +// stream << !statusBar()->isHidden(); // FIXME strange error ???? if (withTabs) stream << tabWidget()->saveState(); else @@ -199,6 +171,8 @@ QByteArray BrowserMainWindow::saveState(bool withTabs) const return data; } + + bool BrowserMainWindow::restoreState(const QByteArray &state) { int version = 2; @@ -229,10 +203,6 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) resize(size); m_navigationBar->setVisible(showToolbar); - updateToolbarActionText(showToolbar); - - m_bookmarksToolbar->setVisible(showBookmarksBar); - updateBookmarksToolbarActionText(showBookmarksBar); statusBar()->setVisible(showStatusbar); updateStatusbarActionText(showStatusbar); @@ -243,145 +213,140 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) return true; } + + void BrowserMainWindow::setupMenu() { new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(slotSwapFocus())); - // File - QMenu *fileMenu = menuBar()->addMenu(tr("&File")); + // ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- + QMenu *fileMenu = menuBar()->addMenu( i18n("&File")); - fileMenu->addAction(tr("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New); + fileMenu->addAction(i18n("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New); fileMenu->addAction(m_tabWidget->newTabAction()); - fileMenu->addAction(tr("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence::Open); - fileMenu->addAction(tr("Open &Location..."), this, - SLOT(slotSelectLineEdit()), QKeySequence(Qt::ControlModifier + Qt::Key_L)); + fileMenu->addAction(i18n("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence::Open); + fileMenu->addAction(i18n("Open &Location..."), this, SLOT(slotSelectLineEdit()), QKeySequence(Qt::ControlModifier + Qt::Key_L)); fileMenu->addSeparator(); + fileMenu->addAction(m_tabWidget->closeTabAction()); fileMenu->addSeparator(); - fileMenu->addAction(tr("&Save As..."), this, - SLOT(slotFileSaveAs()), QKeySequence(QKeySequence::Save)); - fileMenu->addSeparator(); - BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); - fileMenu->addAction(tr("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); - fileMenu->addAction(tr("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); + + fileMenu->addAction(i18n("&Save As..."), this, SLOT(slotFileSaveAs()), QKeySequence(QKeySequence::Save)); fileMenu->addSeparator(); - fileMenu->addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview())); - fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print); + + fileMenu->addAction(i18n("P&rint Preview..."), this, SLOT(slotFilePrintPreview())); + fileMenu->addAction(i18n("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print); fileMenu->addSeparator(); - QAction *action = fileMenu->addAction(tr("Private &Browsing..."), this, SLOT(slotPrivateBrowsing())); + + QAction *action = fileMenu->addAction(i18n("Private &Browsing..."), this, SLOT(slotPrivateBrowsing())); action->setCheckable(true); fileMenu->addSeparator(); #if defined(Q_WS_MAC) - fileMenu->addAction(tr("&Quit"), BrowserApplication::instance(), SLOT(quitBrowser()), QKeySequence(Qt::CTRL | Qt::Key_Q)); + fileMenu->addAction( i18n("&Quit"), BrowserApplication::instance(), SLOT(quitBrowser()), QKeySequence(Qt::CTRL | Qt::Key_Q)); #else - fileMenu->addAction(tr("&Quit"), this, SLOT(close()), QKeySequence(Qt::CTRL | Qt::Key_Q)); + fileMenu->addAction( i18n("&Quit"), this, SLOT(close()), QKeySequence(Qt::CTRL | Qt::Key_Q)); #endif - // Edit - QMenu *editMenu = menuBar()->addMenu(tr("&Edit")); - QAction *m_undo = editMenu->addAction(tr("&Undo")); + // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- + QMenu *editMenu = menuBar()->addMenu(i18n("&Edit")); + + QAction *m_undo = editMenu->addAction(i18n("&Undo")); m_undo->setShortcuts(QKeySequence::Undo); m_tabWidget->addWebAction(m_undo, QWebPage::Undo); - QAction *m_redo = editMenu->addAction(tr("&Redo")); + + QAction *m_redo = editMenu->addAction(i18n("&Redo")); m_redo->setShortcuts(QKeySequence::Redo); m_tabWidget->addWebAction(m_redo, QWebPage::Redo); + editMenu->addSeparator(); - QAction *m_cut = editMenu->addAction(tr("Cu&t")); + + QAction *m_cut = editMenu->addAction(i18n("Cu&t")); m_cut->setShortcuts(QKeySequence::Cut); m_tabWidget->addWebAction(m_cut, QWebPage::Cut); - QAction *m_copy = editMenu->addAction(tr("&Copy")); + + QAction *m_copy = editMenu->addAction(i18n("&Copy")); m_copy->setShortcuts(QKeySequence::Copy); m_tabWidget->addWebAction(m_copy, QWebPage::Copy); - QAction *m_paste = editMenu->addAction(tr("&Paste")); + + QAction *m_paste = editMenu->addAction(i18n("&Paste")); m_paste->setShortcuts(QKeySequence::Paste); m_tabWidget->addWebAction(m_paste, QWebPage::Paste); + editMenu->addSeparator(); - QAction *m_find = editMenu->addAction(tr("&Find")); + QAction *m_find = editMenu->addAction(i18n("&Find")); m_find->setShortcuts(QKeySequence::Find); connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); - QAction *m_findNext = editMenu->addAction(tr("&Find Next")); + QAction *m_findNext = editMenu->addAction( i18n("&Find Next")); m_findNext->setShortcuts(QKeySequence::FindNext); connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); - QAction *m_findPrevious = editMenu->addAction(tr("&Find Previous")); + QAction *m_findPrevious = editMenu->addAction( i18n("&Find Previous")); m_findPrevious->setShortcuts(QKeySequence::FindPrevious); connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); editMenu->addSeparator(); - editMenu->addAction(tr("&Preferences"), this, SLOT(slotPreferences()), tr("Ctrl+,")); + editMenu->addAction( i18n("&Preferences"), this, SLOT(slotPreferences()), i18n("Ctrl+,")); - // View - QMenu *viewMenu = menuBar()->addMenu(tr("&View")); - m_viewBookmarkBar = new QAction(this); - updateBookmarksToolbarActionText(true); - m_viewBookmarkBar->setShortcut(tr("Shift+Ctrl+B")); - connect(m_viewBookmarkBar, SIGNAL(triggered()), this, SLOT(slotViewBookmarksBar())); - viewMenu->addAction(m_viewBookmarkBar); + // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- + QMenu *viewMenu = menuBar()->addMenu( i18n("&View") ); - m_viewToolbar = new QAction(this); - updateToolbarActionText(true); - m_viewToolbar->setShortcut(tr("Ctrl+|")); - connect(m_viewToolbar, SIGNAL(triggered()), this, SLOT(slotViewToolbar())); - viewMenu->addAction(m_viewToolbar); - - m_viewStatusbar = new QAction(this); + m_viewStatusbar = new KAction(this); updateStatusbarActionText(true); - m_viewStatusbar->setShortcut(tr("Ctrl+/")); + m_viewStatusbar->setShortcut( i18n("Ctrl+/") ); connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); viewMenu->addAction(m_viewStatusbar); viewMenu->addSeparator(); - m_stop = viewMenu->addAction(tr("&Stop")); + m_stop = viewMenu->addAction( i18n("&Stop") ); QList shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); shortcuts.append(Qt::Key_Escape); m_stop->setShortcuts(shortcuts); m_tabWidget->addWebAction(m_stop, QWebPage::Stop); - m_reload = viewMenu->addAction(tr("Reload Page")); + m_reload = viewMenu->addAction( i18n("Reload Page") ); m_reload->setShortcuts(QKeySequence::Refresh); m_tabWidget->addWebAction(m_reload, QWebPage::Reload); - viewMenu->addAction(tr("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); - viewMenu->addAction(tr("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); - viewMenu->addAction(tr("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); + viewMenu->addAction( i18n("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); + viewMenu->addAction( i18n("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); + viewMenu->addAction( i18n("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); viewMenu->addSeparator(); - viewMenu->addAction(tr("Page S&ource"), this, SLOT(slotViewPageSource()), tr("Ctrl+Alt+U")); - QAction *a = viewMenu->addAction(tr("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); + viewMenu->addAction( i18n("Page S&ource"), this, SLOT(slotViewPageSource()), i18n("Ctrl+Alt+U")); + QAction *a = viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); a->setCheckable(true); - // History + + // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- HistoryMenu *historyMenu = new HistoryMenu(this); - connect(historyMenu, SIGNAL(openUrl(const QUrl&)), - m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); - connect(historyMenu, SIGNAL(hovered(const QString&)), this, - SLOT(slotUpdateStatusbar(const QString&))); - historyMenu->setTitle(tr("Hi&story")); + connect(historyMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); + historyMenu->setTitle( i18n("Hi&story") ); menuBar()->addMenu(historyMenu); QList historyActions; - m_historyBack = new QAction(tr("Back"), this); + m_historyBack = new QAction( i18n("Back"), this); m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); m_historyBack->setShortcuts(QKeySequence::Back); m_historyBack->setIconVisibleInMenu(false); - m_historyForward = new QAction(tr("Forward"), this); + m_historyForward = new QAction( i18n("Forward"), this); m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); m_historyForward->setShortcuts(QKeySequence::Forward); m_historyForward->setIconVisibleInMenu(false); - QAction *m_historyHome = new QAction(tr("Home"), this); + QAction *m_historyHome = new QAction( i18n("Home"), this); connect(m_historyHome, SIGNAL(triggered()), this, SLOT(slotHome())); m_historyHome->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H)); - m_restoreLastSession = new QAction(tr("Restore Last Session"), this); + m_restoreLastSession = new QAction( i18n("Restore Last Session"), this); connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); @@ -392,20 +357,24 @@ void BrowserMainWindow::setupMenu() historyActions.append(m_restoreLastSession); historyMenu->setInitialActions(historyActions); - // Bookmarks + // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- BookmarksMenu *bookmarksMenu = new BookmarksMenu(this); - connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), - m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); - connect(bookmarksMenu, SIGNAL(hovered(const QString&)), - this, SLOT(slotUpdateStatusbar(const QString&))); - bookmarksMenu->setTitle(tr("&Bookmarks")); + connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(bookmarksMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); + bookmarksMenu->setTitle(i18n("&Bookmarks")); menuBar()->addMenu(bookmarksMenu); + // FIXME +// BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); +// bookmarksMenu->addAction(i18n("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); +// bookmarksMenu->addAction(i18n("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); +// bookmarksMenu->addSeparator(); + QList bookmarksActions; - QAction *showAllBookmarksAction = new QAction(tr("Show All Bookmarks"), this); + QAction *showAllBookmarksAction = new QAction(i18n("Show All Bookmarks"), this); connect(showAllBookmarksAction, SIGNAL(triggered()), this, SLOT(slotShowBookmarksDialog())); - m_addBookmark = new QAction(QIcon(QLatin1String(":addbookmark.png")), tr("Add Bookmark..."), this); + m_addBookmark = new QAction( KIcon("bookmark-new"), i18n("Add Bookmark..."), this); m_addBookmark->setIconVisibleInMenu(false); connect(m_addBookmark, SIGNAL(triggered()), this, SLOT(slotAddBookmark())); @@ -415,73 +384,83 @@ void BrowserMainWindow::setupMenu() bookmarksActions.append(m_addBookmark); bookmarksMenu->setInitialActions(bookmarksActions); - // Window - m_windowMenu = menuBar()->addMenu(tr("&Window")); + // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- + m_windowMenu = menuBar()->addMenu( i18n("&Window")); connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowWindowMenu())); slotAboutToShowWindowMenu(); - QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools")); - toolsMenu->addAction(tr("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence(tr("Ctrl+K", "Web Search"))); + QMenu *toolsMenu = menuBar()->addMenu( i18n("&Tools")); + toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); #ifndef Q_CC_MINGW - a = toolsMenu->addAction(tr("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); + a = toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); a->setCheckable(true); #endif - QMenu *helpMenu = menuBar()->addMenu(tr("&Help")); - helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); - helpMenu->addAction(tr("About &Demo Browser"), this, SLOT(slotAboutApplication())); + QMenu *helpMenu = menuBar()->addMenu( i18n("&Help")); + helpMenu->addAction( i18n("About &Qt"), qApp, SLOT(aboutQt())); + helpMenu->addAction( i18n("About &reKonq"), this, SLOT(slotAboutApplication())); } + + + + void BrowserMainWindow::setupToolBar() { setUnifiedTitleAndToolBarOnMac(true); - m_navigationBar = addToolBar(tr("Navigation")); - connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), - this, SLOT(updateToolbarActionText(bool))); - m_historyBack->setIcon(style()->standardIcon(QStyle::SP_ArrowBack, 0, this)); + m_navigationBar = addToolBar(i18n("Navigation")); + connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); + + m_historyBack->setIcon( KIcon("go-previous") ); m_historyBackMenu = new QMenu(this); m_historyBack->setMenu(m_historyBackMenu); - connect(m_historyBackMenu, SIGNAL(aboutToShow()), - this, SLOT(slotAboutToShowBackMenu())); - connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), - this, SLOT(slotOpenActionUrl(QAction *))); + connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); + connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); m_navigationBar->addAction(m_historyBack); - m_historyForward->setIcon(style()->standardIcon(QStyle::SP_ArrowForward, 0, this)); - m_historyForwardMenu = new QMenu(this); - connect(m_historyForwardMenu, SIGNAL(aboutToShow()), - this, SLOT(slotAboutToShowForwardMenu())); - connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), - this, SLOT(slotOpenActionUrl(QAction *))); + m_historyForward->setIcon( KIcon("go-next") ); + m_historyForwardMenu = new QMenu(this); + connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowForwardMenu())); + connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); m_historyForward->setMenu(m_historyForwardMenu); m_navigationBar->addAction(m_historyForward); m_stopReload = new QAction(this); - m_reloadIcon = style()->standardIcon(QStyle::SP_BrowserReload); + m_reloadIcon = KIcon( "view-refresh" ); m_stopReload->setIcon(m_reloadIcon); - m_navigationBar->addAction(m_stopReload); + m_goHome = new QAction(this); + m_goHome->setIcon( KIcon( "go-home" ) ); + m_navigationBar->addAction(m_goHome); + connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); + m_navigationBar->addWidget(m_tabWidget->lineEditStack()); m_toolbarSearch = new ToolbarSearch(m_navigationBar); m_navigationBar->addWidget(m_toolbarSearch); - connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); - m_chaseWidget = new ChaseWidget(this); - m_navigationBar->addWidget(m_chaseWidget); + // fixing toolbar movements + m_navigationBar->setFloatable( false ); + + connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); } + + + void BrowserMainWindow::slotShowBookmarksDialog() { BookmarksDialog *dialog = new BookmarksDialog(this); - connect(dialog, SIGNAL(openUrl(const QUrl&)), - m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(dialog, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); dialog->show(); } + + + void BrowserMainWindow::slotAddBookmark() { WebView *webView = currentTab(); @@ -491,44 +470,14 @@ void BrowserMainWindow::slotAddBookmark() dialog.exec(); } -void BrowserMainWindow::slotViewToolbar() -{ - if (m_navigationBar->isVisible()) { - updateToolbarActionText(false); - m_navigationBar->close(); - } else { - updateToolbarActionText(true); - m_navigationBar->show(); - } - m_autoSaver->changeOccurred(); -} - -void BrowserMainWindow::slotViewBookmarksBar() -{ - if (m_bookmarksToolbar->isVisible()) { - updateBookmarksToolbarActionText(false); - m_bookmarksToolbar->close(); - } else { - updateBookmarksToolbarActionText(true); - m_bookmarksToolbar->show(); - } - m_autoSaver->changeOccurred(); -} void BrowserMainWindow::updateStatusbarActionText(bool visible) { - m_viewStatusbar->setText(!visible ? tr("Show Status Bar") : tr("Hide Status Bar")); + m_viewStatusbar->setText(!visible ? i18n("Show Status Bar") : i18n("Hide Status Bar")); } -void BrowserMainWindow::updateToolbarActionText(bool visible) -{ - m_viewToolbar->setText(!visible ? tr("Show Toolbar") : tr("Hide Toolbar")); -} -void BrowserMainWindow::updateBookmarksToolbarActionText(bool visible) -{ - m_viewBookmarkBar->setText(!visible ? tr("Show Bookmarks bar") : tr("Hide Bookmarks bar")); -} + void BrowserMainWindow::slotViewStatusbar() { @@ -542,6 +491,9 @@ void BrowserMainWindow::slotViewStatusbar() m_autoSaver->changeOccurred(); } + + + QUrl BrowserMainWindow::guessUrlFromString(const QString &string) { QString urlStr = string.trimmed(); @@ -582,62 +534,81 @@ QUrl BrowserMainWindow::guessUrlFromString(const QString &string) return url; } + + + void BrowserMainWindow::loadUrl(const QUrl &url) { loadPage(url.toString()); } + + + void BrowserMainWindow::slotDownloadManager() { BrowserApplication::downloadManager()->show(); } + + void BrowserMainWindow::slotSelectLineEdit() { m_tabWidget->currentLineEdit()->selectAll(); m_tabWidget->currentLineEdit()->setFocus(); } + + void BrowserMainWindow::slotFileSaveAs() { BrowserApplication::downloadManager()->download(currentTab()->url(), true); } + + + void BrowserMainWindow::slotPreferences() { SettingsDialog *s = new SettingsDialog(this); s->show(); } + + + void BrowserMainWindow::slotUpdateStatusbar(const QString &string) { statusBar()->showMessage(string, 2000); } + + + void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) { if (title.isEmpty()) { - setWindowTitle(tr("Qt Demo Browser")); + setWindowTitle("reKonq"); } else { -#if defined(Q_WS_MAC) - setWindowTitle(title); -#else - setWindowTitle(tr("%1 - Qt Demo Browser", "Page title and Browser name").arg(title)); -#endif + setWindowTitle(title + " - reKonq"); } } + + + void BrowserMainWindow::slotAboutApplication() { - QMessageBox::about(this, tr("About"), tr( - "Version %1" - "

This demo demonstrates Qt's " - "webkit facilities in action, providing an example " - "browser for you to experiment with.

" + QMessageBox::about(this, i18n("About"), + i18n( + "

reKonq is a simple KDE dedicated browser" + "

webkit and Qt Demo Browser based." // FIXME go new line.. "

QtWebKit is based on the Open Source WebKit Project developed at http://webkit.org/." - ).arg(QCoreApplication::applicationVersion())); + )); } + + void BrowserMainWindow::slotFileNew() { BrowserApplication::instance()->newMainWindow(); @@ -645,10 +616,13 @@ void BrowserMainWindow::slotFileNew() mw->slotHome(); } + + + void BrowserMainWindow::slotFileOpen() { - QString file = QFileDialog::getOpenFileName(this, tr("Open Web Resource"), QString(), - tr("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)")); + QString file = QFileDialog::getOpenFileName(this, i18n("Open Web Resource"), QString(), + i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)")); if (file.isEmpty()) return; @@ -656,6 +630,9 @@ void BrowserMainWindow::slotFileOpen() loadPage(file); } + + + void BrowserMainWindow::slotFilePrintPreview() { if (!currentTab()) @@ -666,6 +643,8 @@ void BrowserMainWindow::slotFilePrintPreview() dialog->exec(); } + + void BrowserMainWindow::slotFilePrint() { if (!currentTab()) @@ -673,30 +652,34 @@ void BrowserMainWindow::slotFilePrint() printRequested(currentTab()->page()->mainFrame()); } + + void BrowserMainWindow::printRequested(QWebFrame *frame) { QPrinter printer; QPrintDialog *dialog = new QPrintDialog(&printer, this); - dialog->setWindowTitle(tr("Print Document")); + dialog->setWindowTitle( i18n("Print Document") ); if (dialog->exec() != QDialog::Accepted) return; frame->print(&printer); } + + void BrowserMainWindow::slotPrivateBrowsing() { QWebSettings *settings = QWebSettings::globalSettings(); bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); if (!pb) { - QString title = tr("Are you sure you want to turn on private browsing?"); - QString text = tr("%1

When private browsing in turned on," + QString title = i18n("Are you sure you want to turn on private browsing?"); + QString text = "" + title + i18n("

When private browsing in turned on," " webpages are not added to the history," " items are automatically removed from the Downloads window," \ " new cookies are not stored, current cookies can't be accessed," \ " site icons wont be stored, session wont be saved, " \ " and searches are not addded to the pop-up menu in the Google search box." \ " Until you close the window, you can still click the Back and Forward buttons" \ - " to return to the webpages you have opened.").arg(title); + " to return to the webpages you have opened."); QMessageBox::StandardButton button = QMessageBox::question(this, QString(), text, QMessageBox::Ok | QMessageBox::Cancel, @@ -716,12 +699,14 @@ void BrowserMainWindow::slotPrivateBrowsing() } } + + void BrowserMainWindow::closeEvent(QCloseEvent *event) { if (m_tabWidget->count() > 1) { int ret = QMessageBox::warning(this, QString(), - tr("Are you sure you want to close the window?" - " There are %1 tab open").arg(m_tabWidget->count()), + i18n("Are you sure you want to close the window?" + " There are %1 tab open" , m_tabWidget->count() ) , QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (ret == QMessageBox::No) { @@ -733,21 +718,26 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event) deleteLater(); } + + + void BrowserMainWindow::slotEditFind() { if (!currentTab()) return; bool ok; - QString search = QInputDialog::getText(this, tr("Find"), - tr("Text:"), QLineEdit::Normal, + QString search = QInputDialog::getText(this, i18n("Find"), + i18n("Text:"), QLineEdit::Normal, m_lastSearch, &ok); if (ok && !search.isEmpty()) { m_lastSearch = search; if (!currentTab()->findText(m_lastSearch)) - slotUpdateStatusbar(tr("\"%1\" not found.").arg(m_lastSearch)); + slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); } } + + void BrowserMainWindow::slotEditFindNext() { if (!currentTab() && !m_lastSearch.isEmpty()) @@ -755,6 +745,8 @@ void BrowserMainWindow::slotEditFindNext() currentTab()->findText(m_lastSearch); } + + void BrowserMainWindow::slotEditFindPrevious() { if (!currentTab() && !m_lastSearch.isEmpty()) @@ -762,6 +754,8 @@ void BrowserMainWindow::slotEditFindPrevious() currentTab()->findText(m_lastSearch, QWebPage::FindBackward); } + + void BrowserMainWindow::slotViewTextBigger() { if (!currentTab()) @@ -769,6 +763,8 @@ void BrowserMainWindow::slotViewTextBigger() currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() + 0.1); } + + void BrowserMainWindow::slotViewTextNormal() { if (!currentTab()) @@ -776,6 +772,8 @@ void BrowserMainWindow::slotViewTextNormal() currentTab()->setTextSizeMultiplier(1.0); } + + void BrowserMainWindow::slotViewTextSmaller() { if (!currentTab()) @@ -783,6 +781,9 @@ void BrowserMainWindow::slotViewTextSmaller() currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() - 0.1); } + + + void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) { if (makeFullScreen) { @@ -796,6 +797,9 @@ void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) } } + + + void BrowserMainWindow::slotViewPageSource() { if (!currentTab()) @@ -803,32 +807,40 @@ void BrowserMainWindow::slotViewPageSource() QString markup = currentTab()->page()->mainFrame()->toHtml(); QPlainTextEdit *view = new QPlainTextEdit(markup); - view->setWindowTitle(tr("Page Source of %1").arg(currentTab()->title())); + view->setWindowTitle( i18n("Page Source of ") + currentTab()->title() ); view->setMinimumWidth(640); view->setAttribute(Qt::WA_DeleteOnClose); view->show(); } + + void BrowserMainWindow::slotHome() { QSettings settings; settings.beginGroup(QLatin1String("MainWindow")); - QString home = settings.value(QLatin1String("home"), QLatin1String("http://www.trolltech.com/")).toString(); + QString home = settings.value(QLatin1String("home"), QLatin1String("http://www.kde.org/")).toString(); loadPage(home); } + + + void BrowserMainWindow::slotWebSearch() { m_toolbarSearch->lineEdit()->selectAll(); m_toolbarSearch->lineEdit()->setFocus(); } + + + void BrowserMainWindow::slotToggleInspector(bool enable) { QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); if (enable) { - int result = QMessageBox::question(this, tr("Web Inspector"), - tr("The web inspector will only work correctly for pages that were loaded after enabling.\n" + int result = QMessageBox::question(this, i18n("Web Inspector"), + i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" "Do you want to reload all pages?"), QMessageBox::Yes | QMessageBox::No); if (result == QMessageBox::Yes) { @@ -837,6 +849,9 @@ void BrowserMainWindow::slotToggleInspector(bool enable) } } + + + void BrowserMainWindow::slotSwapFocus() { if (currentTab()->hasFocus()) @@ -845,6 +860,8 @@ void BrowserMainWindow::slotSwapFocus() currentTab()->setFocus(); } + + void BrowserMainWindow::loadPage(const QString &page) { if (!currentTab() || page.isEmpty()) @@ -855,35 +872,43 @@ void BrowserMainWindow::loadPage(const QString &page) m_tabWidget->loadUrlInCurrentTab(url); } + + + TabWidget *BrowserMainWindow::tabWidget() const { return m_tabWidget; } + + WebView *BrowserMainWindow::currentTab() const { return m_tabWidget->currentWebView(); } + + void BrowserMainWindow::slotLoadProgress(int progress) { if (progress < 100 && progress > 0) { - m_chaseWidget->setAnimated(true); disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); if (m_stopIcon.isNull()) - m_stopIcon = style()->standardIcon(QStyle::SP_BrowserStop); + m_stopIcon = KIcon( style()->standardIcon(QStyle::SP_BrowserStop) ); m_stopReload->setIcon(m_stopIcon); connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); - m_stopReload->setToolTip(tr("Stop loading the current page")); + m_stopReload->setToolTip( i18n("Stop loading the current page") ); } else { - m_chaseWidget->setAnimated(false); disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); m_stopReload->setIcon(m_reloadIcon); connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); - m_stopReload->setToolTip(tr("Reload the current page")); + m_stopReload->setToolTip( i18n("Reload the current page") ); } } + + + void BrowserMainWindow::slotAboutToShowBackMenu() { m_historyBackMenu->clear(); @@ -893,7 +918,7 @@ void BrowserMainWindow::slotAboutToShowBackMenu() int historyCount = history->count(); for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { QWebHistoryItem item = history->backItems(history->count()).at(i); - QAction *action = new QAction(this); + KAction *action = new KAction(this); action->setData(-1*(historyCount-i-1)); QIcon icon = BrowserApplication::instance()->icon(item.url()); action->setIcon(icon); @@ -902,6 +927,9 @@ void BrowserMainWindow::slotAboutToShowBackMenu() } } + + + void BrowserMainWindow::slotAboutToShowForwardMenu() { m_historyForwardMenu->clear(); @@ -920,13 +948,16 @@ void BrowserMainWindow::slotAboutToShowForwardMenu() } } + + + void BrowserMainWindow::slotAboutToShowWindowMenu() { m_windowMenu->clear(); m_windowMenu->addAction(m_tabWidget->nextTabAction()); m_windowMenu->addAction(m_tabWidget->previousTabAction()); m_windowMenu->addSeparator(); - m_windowMenu->addAction(tr("Downloads"), this, SLOT(slotDownloadManager()), QKeySequence(tr("Alt+Ctrl+L", "Download Manager"))); + m_windowMenu->addAction( i18n("Downloads"), this, SLOT(slotDownloadManager()), QKeySequence( tr("Alt+Ctrl+L", "Download Manager"))); m_windowMenu->addSeparator(); QList windows = BrowserApplication::instance()->mainWindows(); @@ -940,9 +971,12 @@ void BrowserMainWindow::slotAboutToShowWindowMenu() } } + + + void BrowserMainWindow::slotShowWindow() { - if (QAction *action = qobject_cast(sender())) { + if (KAction *action = qobject_cast(sender())) { QVariant v = action->data(); if (v.canConvert()) { int offset = qvariant_cast(v); @@ -953,6 +987,9 @@ void BrowserMainWindow::slotShowWindow() } } + + + void BrowserMainWindow::slotOpenActionUrl(QAction *action) { int offset = action->data().toInt(); @@ -963,7 +1000,11 @@ void BrowserMainWindow::slotOpenActionUrl(QAction *action) history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward } + + + void BrowserMainWindow::geometryChangeRequested(const QRect &geometry) { setGeometry(geometry); } + diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 17f87056..aba3d61d 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -1,50 +1,36 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #ifndef BROWSERMAINWINDOW_H #define BROWSERMAINWINDOW_H -#include -#include -#include +#include +#include +#include +#include +#include + +#include class AutoSaver; -class BookmarksToolBar; -class ChaseWidget; +// class ChaseWidget; class QWebFrame; class TabWidget; class ToolbarSearch; @@ -55,7 +41,7 @@ class WebView; Handles the tab widget and all the actions */ -class BrowserMainWindow : public QMainWindow { +class BrowserMainWindow : public KMainWindow { Q_OBJECT public: @@ -101,8 +87,6 @@ private slots: void slotViewTextBigger(); void slotViewTextNormal(); void slotViewTextSmaller(); - void slotViewToolbar(); - void slotViewBookmarksBar(); void slotViewStatusbar(); void slotViewPageSource(); void slotViewFullScreen(bool enable); @@ -122,8 +106,6 @@ private slots: void printRequested(QWebFrame *frame); void geometryChangeRequested(const QRect &geometry); - void updateToolbarActionText(bool visible); - void updateBookmarksToolbarActionText(bool visible); private: void loadDefaultState(); @@ -134,8 +116,6 @@ private: private: QToolBar *m_navigationBar; ToolbarSearch *m_toolbarSearch; - BookmarksToolBar *m_bookmarksToolbar; - ChaseWidget *m_chaseWidget; TabWidget *m_tabWidget; AutoSaver *m_autoSaver; @@ -148,14 +128,13 @@ private: QAction *m_stop; QAction *m_reload; QAction *m_stopReload; - QAction *m_viewToolbar; - QAction *m_viewBookmarkBar; + QAction *m_goHome; QAction *m_viewStatusbar; QAction *m_restoreLastSession; QAction *m_addBookmark; - QIcon m_reloadIcon; - QIcon m_stopIcon; + KIcon m_reloadIcon; + KIcon m_stopIcon; QString m_lastSearch; }; diff --git a/src/chasewidget.cpp b/src/chasewidget.cpp deleted file mode 100644 index ea2b0f8e..00000000 --- a/src/chasewidget.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - -#include "chasewidget.h" - -#include - -#include -#include -#include -#include -#include - -ChaseWidget::ChaseWidget(QWidget *parent, QPixmap pixmap, bool pixmapEnabled) - : QWidget(parent) - , m_segment(0) - , m_delay(100) - , m_step(40) - , m_timerId(-1) - , m_animated(false) - , m_pixmap(pixmap) - , m_pixmapEnabled(pixmapEnabled) -{ -} - -void ChaseWidget::setAnimated(bool value) -{ - if (m_animated == value) - return; - m_animated = value; - if (m_timerId != -1) { - killTimer(m_timerId); - m_timerId = -1; - } - if (m_animated) { - m_segment = 0; - m_timerId = startTimer(m_delay); - } - update(); -} - -void ChaseWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainter p(this); - if (m_pixmapEnabled && !m_pixmap.isNull()) { - p.drawPixmap(0, 0, m_pixmap); - return; - } - - const int extent = qMin(width() - 8, height() - 8); - const int displ = extent / 4; - const int ext = extent / 4 - 1; - - p.setRenderHint(QPainter::Antialiasing, true); - - if(m_animated) - p.setPen(Qt::gray); - else - p.setPen(QPen(palette().dark().color())); - - p.translate(width() / 2, height() / 2); // center - - for (int segment = 0; segment < segmentCount(); ++segment) { - p.rotate(QApplication::isRightToLeft() ? m_step : -m_step); - if(m_animated) - p.setBrush(colorForSegment(segment)); - else - p.setBrush(palette().background()); - p.drawEllipse(QRect(displ, -ext / 2, ext, ext)); - } -} - -QSize ChaseWidget::sizeHint() const -{ - return QSize(32, 32); -} - -void ChaseWidget::timerEvent(QTimerEvent *event) -{ - if (event->timerId() == m_timerId) { - ++m_segment; - update(); - } - QWidget::timerEvent(event); -} - -QColor ChaseWidget::colorForSegment(int seg) const -{ - int index = ((seg + m_segment) % segmentCount()); - int comp = qMax(0, 255 - (index * (255 / segmentCount()))); - return QColor(comp, comp, comp, 255); -} - -int ChaseWidget::segmentCount() const -{ - return 360 / m_step; -} - -void ChaseWidget::setPixmapEnabled(bool enable) -{ - m_pixmapEnabled = enable; -} - diff --git a/src/chasewidget.h b/src/chasewidget.h deleted file mode 100644 index ce5b2dae..00000000 --- a/src/chasewidget.h +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - -#ifndef CHASEWIDGET_H -#define CHASEWIDGET_H - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QHideEvent; -class QShowEvent; -class QPaintEvent; -class QTimerEvent; -QT_END_NAMESPACE - -class ChaseWidget : public QWidget -{ - Q_OBJECT -public: - ChaseWidget(QWidget *parent = 0, QPixmap pixmap = QPixmap(), bool pixmapEnabled = false); - - void setAnimated(bool value); - void setPixmapEnabled(bool enable); - QSize sizeHint() const; - -protected: - void paintEvent(QPaintEvent *event); - void timerEvent(QTimerEvent *event); - -private: - int segmentCount() const; - QColor colorForSegment(int segment) const; - - int m_segment; - int m_delay; - int m_step; - int m_timerId; - bool m_animated; - QPixmap m_pixmap; - bool m_pixmapEnabled; -}; - -#endif diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index bed7258a..098506c9 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -1,62 +1,43 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes #include "cookiejar.h" - #include "autosaver.h" -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include +// Qt Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include static const unsigned int JAR_VERSION = 23; @@ -392,17 +373,17 @@ QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int r switch (section) { case 0: - return tr("Website"); + return i18n("Website"); case 1: - return tr("Name"); + return i18n("Name"); case 2: - return tr("Path"); + return i18n("Path"); case 3: - return tr("Secure"); + return i18n("Secure"); case 4: - return tr("Expires"); + return i18n("Expires"); case 5: - return tr("Contents"); + return i18n("Contents"); default: return QVariant(); } @@ -547,9 +528,9 @@ QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientat && role == Qt::DisplayRole) { switch (section) { case 0: - return tr("Website"); + return i18n("Website"); case 1: - return tr("Status"); + return i18n("Status"); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -569,7 +550,7 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const case 0: return m_allowedCookies.at(row); case 1: - return tr("Allow"); + return i18n("Allow"); } } row = row - m_allowedCookies.count(); @@ -578,7 +559,7 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const case 0: return m_blockedCookies.at(row); case 1: - return tr("Block"); + return i18n("Block"); } } row = row - m_blockedCookies.count(); @@ -587,7 +568,7 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const case 0: return m_sessionCookies.at(row); case 1: - return tr("Allow For Session"); + return i18n("Allow For Session"); } } } diff --git a/src/data/addtab.png b/src/data/addtab.png deleted file mode 100644 index 20928fb4..00000000 Binary files a/src/data/addtab.png and /dev/null differ diff --git a/src/data/browser.svg b/src/data/browser.svg deleted file mode 100644 index c42af2bc..00000000 --- a/src/data/browser.svg +++ /dev/null @@ -1,1598 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/data/closetab.png b/src/data/closetab.png deleted file mode 100644 index ab9d669e..00000000 Binary files a/src/data/closetab.png and /dev/null differ diff --git a/src/data/data.qrc b/src/data/data.qrc deleted file mode 100644 index c7d0294c..00000000 --- a/src/data/data.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - addtab.png - closetab.png - history.png - browser.svg - defaultbookmarks.xbel - loading.gif - defaulticon.png - - diff --git a/src/data/defaultbookmarks.xbel b/src/data/defaultbookmarks.xbel deleted file mode 100644 index f1c9253d..00000000 --- a/src/data/defaultbookmarks.xbel +++ /dev/null @@ -1,40 +0,0 @@ - - - - - Bookmarks Bar - - Trolltech.com - - - WebKit.org - - - Qt Documentation - - - Qt Quarterly - - - Trolltech Labs - - - Qt Centre - - - Qt-Apps.org - - - qtnode - - - xkcd - - - - Bookmarks Menu - - reddit.com: what's new online! - - - diff --git a/src/data/defaulticon.png b/src/data/defaulticon.png deleted file mode 100644 index 01a0920c..00000000 Binary files a/src/data/defaulticon.png and /dev/null differ diff --git a/src/data/history.png b/src/data/history.png deleted file mode 100644 index 552a1cbd..00000000 Binary files a/src/data/history.png and /dev/null differ diff --git a/src/data/loading.gif b/src/data/loading.gif deleted file mode 100644 index c1545eb0..00000000 Binary files a/src/data/loading.gif and /dev/null differ diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index d8f19c5e..e3254cba 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,59 +1,41 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local includes #include "downloadmanager.h" - #include "autosaver.h" #include "browserapplication.h" #include "networkaccessmanager.h" +// generic includes #include -#include -#include - -#include -#include -#include -#include - -#include - -#include +// Qt Includes +#include +#include +#include +#include +#include +#include +#include +#include /*! DownloadItem is a widget that is displayed in the download manager list. @@ -88,14 +70,10 @@ void DownloadItem::init() m_url = m_reply->url(); m_reply->setParent(this); connect(m_reply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead())); - connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), - this, SLOT(error(QNetworkReply::NetworkError))); - connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), - this, SLOT(downloadProgress(qint64, qint64))); - connect(m_reply, SIGNAL(metaDataChanged()), - this, SLOT(metaDataChanged())); - connect(m_reply, SIGNAL(finished()), - this, SLOT(finished())); + connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); + connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64))); + connect(m_reply, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged())); + connect(m_reply, SIGNAL(finished()), this, SLOT(finished())); // reset info downloadInfoLabel->clear(); @@ -123,10 +101,10 @@ void DownloadItem::getFileName() QString defaultFileName = saveFileName(downloadDirectory); QString fileName = defaultFileName; if (m_requestFileName) { - fileName = QFileDialog::getSaveFileName(this, tr("Save File"), defaultFileName); + fileName = QFileDialog::getSaveFileName(this, i18n("Save File"), defaultFileName); if (fileName.isEmpty()) { m_reply->close(); - fileNameLabel->setText(tr("Download canceled: %1").arg(QFileInfo(defaultFileName).fileName())); + fileNameLabel->setText( i18n("Download canceled: ") + QFileInfo(defaultFileName).fileName()); return; } } @@ -208,8 +186,7 @@ void DownloadItem::downloadReadyRead() if (!m_requestFileName) getFileName(); if (!m_output.open(QIODevice::WriteOnly)) { - downloadInfoLabel->setText(tr("Error opening save file: %1") - .arg(m_output.errorString())); + downloadInfoLabel->setText( i18n("Error opening save file: ") + m_output.errorString() ); stopButton->click(); emit statusChanged(); return; @@ -217,8 +194,7 @@ void DownloadItem::downloadReadyRead() emit statusChanged(); } if (-1 == m_output.write(m_reply->readAll())) { - downloadInfoLabel->setText(tr("Error saving: %1") - .arg(m_output.errorString())); + downloadInfoLabel->setText( i18n("Error saving: ") + m_output.errorString() ); stopButton->click(); } } @@ -226,7 +202,7 @@ void DownloadItem::downloadReadyRead() void DownloadItem::error(QNetworkReply::NetworkError) { qDebug() << "DownloadItem::error" << m_reply->errorString() << m_url; - downloadInfoLabel->setText(tr("Network Error: %1").arg(m_reply->errorString())); + downloadInfoLabel->setText( i18n("Network Error: ") + m_reply->errorString() ); tryAgainButton->setEnabled(true); tryAgainButton->setVisible(true); } @@ -260,10 +236,10 @@ void DownloadItem::updateInfoLabel() // update info label double speed = m_bytesReceived * 1000.0 / m_downloadTime.elapsed(); double timeRemaining = ((double)(bytesTotal - m_bytesReceived)) / speed; - QString timeRemainingString = tr("seconds"); + QString timeRemainingString = i18n("seconds"); if (timeRemaining > 60) { timeRemaining = timeRemaining / 60; - timeRemainingString = tr("minutes"); + timeRemainingString = i18n("minutes"); } timeRemaining = floor(timeRemaining); @@ -275,21 +251,13 @@ void DownloadItem::updateInfoLabel() if (running) { QString remaining; if (bytesTotal != 0) - remaining = tr("- %4 %5 remaining") - .arg(timeRemaining) - .arg(timeRemainingString); - info = QString(tr("%1 of %2 (%3/sec) %4")) - .arg(dataString(m_bytesReceived)) - .arg(bytesTotal == 0 ? tr("?") : dataString(bytesTotal)) - .arg(dataString((int)speed)) - .arg(remaining); + remaining = i18n("- %1 %2 remaining", timeRemaining, timeRemainingString ); + info = dataString(m_bytesReceived) + i18n("of") + bytesTotal == 0 ? "?" : dataString(bytesTotal) + "(" + dataString((int)speed) + "/sec)" + QString(remaining); } else { if (m_bytesReceived == bytesTotal) info = dataString(m_output.size()); else - info = tr("%1 of %2 - Stopped") - .arg(dataString(m_bytesReceived)) - .arg(dataString(bytesTotal)); + info = dataString(m_bytesReceived) + i18n("of") + dataString(bytesTotal) + i18n(" - Stopped"); } downloadInfoLabel->setText(info); } @@ -298,13 +266,13 @@ QString DownloadItem::dataString(int size) const { QString unit; if (size < 1024) { - unit = tr("bytes"); + unit = i18n("bytes"); } else if (size < 1024*1024) { size /= 1024; - unit = tr("kB"); + unit = i18n("kB"); } else { size /= 1024*1024; - unit = tr("MB"); + unit = i18n("MB"); } return QString(QLatin1String("%1 %2")).arg(size).arg(unit); } @@ -531,7 +499,7 @@ void DownloadManager::cleanup() void DownloadManager::updateItemCount() { int count = m_downloads.count(); - itemCount->setText(count == 1 ? tr("1 Download") : tr("%1 Downloads").arg(count)); + itemCount->setText(count == 1 ? i18n("1 Download") : QString(count) + i18n(" Downloads") ); } DownloadModel::DownloadModel(DownloadManager *downloadManager, QObject *parent) diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 6f27622b..af33ea12 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #ifndef DOWNLOADMANAGER_H #define DOWNLOADMANAGER_H @@ -41,10 +24,10 @@ #include "ui_downloads.h" #include "ui_downloaditem.h" -#include +#include +#include +#include -#include -#include class DownloadItem : public QWidget, public Ui_DownloadItem { diff --git a/src/history.cpp b/src/history.cpp index fef1920c..985a03ac 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1,64 +1,47 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #include "history.h" #include "autosaver.h" #include "browserapplication.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include -#include +#include static const unsigned int HISTORY_VERSION = 23; @@ -71,12 +54,9 @@ HistoryManager::HistoryManager(QObject *parent) , m_historyTreeModel(0) { m_expiredTimer.setSingleShot(true); - connect(&m_expiredTimer, SIGNAL(timeout()), - this, SLOT(checkForExpired())); - connect(this, SIGNAL(entryAdded(const HistoryItem &)), - m_saveTimer, SLOT(changeOccurred())); - connect(this, SIGNAL(entryRemoved(const HistoryItem &)), - m_saveTimer, SLOT(changeOccurred())); + connect(&m_expiredTimer, SIGNAL(timeout()), this, SLOT(checkForExpired())); + connect(this, SIGNAL(entryAdded(const HistoryItem &)), m_saveTimer, SLOT(changeOccurred())); + connect(this, SIGNAL(entryRemoved(const HistoryItem &)), m_saveTimer, SLOT(changeOccurred())); load(); m_historyModel = new HistoryModel(this, this); @@ -363,15 +343,10 @@ HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) , m_history(history) { Q_ASSERT(m_history); - connect(m_history, SIGNAL(historyReset()), - this, SLOT(historyReset())); - connect(m_history, SIGNAL(entryRemoved(const HistoryItem &)), - this, SLOT(historyReset())); - - connect(m_history, SIGNAL(entryAdded(const HistoryItem &)), - this, SLOT(entryAdded())); - connect(m_history, SIGNAL(entryUpdated(int)), - this, SLOT(entryUpdated(int))); + connect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset())); + connect(m_history, SIGNAL(entryRemoved(const HistoryItem &)), this, SLOT(historyReset())); + connect(m_history, SIGNAL(entryAdded(const HistoryItem &)), this, SLOT(entryAdded())); + connect(m_history, SIGNAL(entryUpdated(int)), this, SLOT(entryUpdated(int))); } void HistoryModel::historyReset() @@ -396,8 +371,8 @@ QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { switch (section) { - case 0: return tr("Title"); - case 1: return tr("Address"); + case 0: return i18n("Title"); + case 1: return i18n("Address"); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -623,11 +598,11 @@ void HistoryMenu::postPopulated() if (m_history->history().count() > 0) addSeparator(); - QAction *showAllAction = new QAction(tr("Show All History"), this); + QAction *showAllAction = new QAction( i18n("Show All History"), this); connect(showAllAction, SIGNAL(triggered()), this, SLOT(showHistoryDialog())); addAction(showAllAction); - QAction *clearAction = new QAction(tr("Clear History"), this); + QAction *clearAction = new QAction( i18n("Clear History"), this); connect(clearAction, SIGNAL(triggered()), m_history, SLOT(clear())); addAction(clearAction); } @@ -696,11 +671,11 @@ void HistoryDialog::customContextMenuRequested(const QPoint &pos) QModelIndex index = tree->indexAt(pos); index = index.sibling(index.row(), 0); if (index.isValid() && !tree->model()->hasChildren(index)) { - menu.addAction(tr("Open"), this, SLOT(open())); + menu.addAction( i18n("Open"), this, SLOT(open())); menu.addSeparator(); - menu.addAction(tr("Copy"), this, SLOT(copy())); + menu.addAction( i18n("Copy"), this, SLOT(copy())); } - menu.addAction(tr("Delete"), tree, SLOT(removeOne())); + menu.addAction( i18n("Delete"), tree, SLOT(removeOne())); menu.exec(QCursor::pos()); } @@ -1029,16 +1004,16 @@ QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const QModelIndex idx = sourceModel()->index(offset, 0); QDate date = idx.data(HistoryModel::DateRole).toDate(); if (date == QDate::currentDate()) - return tr("Earlier Today"); + return i18n("Earlier Today"); return date.toString(QLatin1String("dddd, MMMM d, yyyy")); } if (index.column() == 1) { - return tr("%1 items").arg(rowCount(index.sibling(index.row(), 0))); + return QString(rowCount(index.sibling(index.row(), 0))) + i18n(" items") ; } } } if (role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid()) - return QIcon(QLatin1String(":history.png")); + return KIcon("view-history"); if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) { int offset = sourceDateRow(index.row()); QModelIndex idx = sourceModel()->index(offset, 0); diff --git a/src/history.h b/src/history.h index cda78a5a..1a4a0743 100644 --- a/src/history.h +++ b/src/history.h @@ -1,53 +1,36 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #ifndef HISTORY_H #define HISTORY_H +// Local Includes #include "modelmenu.h" -#include -#include -#include -#include -#include - -#include - +// Qt Includes +#include +#include +#include +#include +#include +#include #include class HistoryItem diff --git a/src/htmls/htmls.qrc b/src/htmls/htmls.qrc deleted file mode 100644 index 03b256cc..00000000 --- a/src/htmls/htmls.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - notfound.html - - diff --git a/src/htmls/notfound.html b/src/htmls/notfound.html deleted file mode 100755 index b428a6a3..00000000 --- a/src/htmls/notfound.html +++ /dev/null @@ -1,63 +0,0 @@ - - -%1 - - - -

- -

%2

-

When connecting to: %3.

-
    -
  • Check the address for errors such as ww.trolltech.com - instead of www.trolltech.com
  • -
  • If the address is correct, try to check the network - connection.
  • -
  • If your computer or network is protected by a firewall or - proxy, make sure that the browser demo is permitted to access - the network.
  • -
-

-
- - diff --git a/src/main.cpp b/src/main.cpp index badfd296..d99226cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -41,7 +41,7 @@ int main(int argc, char **argv) ); aboutData.addAuthor(ki18n("Andrea Diamantini"), ki18n("reKonq author"), "adjam7@gmail.com"); - aboutData.setProgramIconName("application-internet"); + aboutData.setProgramIconName("applications-internet"); KCmdLineArgs::init( argc, argv, &aboutData ); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 8922c8c0..f09a39ab 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -1,58 +1,41 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes #include "networkaccessmanager.h" - #include "browserapplication.h" #include "browsermainwindow.h" #include "ui_passworddialog.h" #include "ui_proxy.h" -#include - -#include -#include -#include -#include +// Qt Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include NetworkAccessManager::NetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent) @@ -99,8 +82,7 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent passwordDialog.iconLabel->setText(QString()); passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); - QString introMessage = tr("Enter username and password for \"%1\" at %2"); - introMessage = introMessage.arg(Qt::escape(reply->url().toString())).arg(Qt::escape(reply->url().toString())); + QString introMessage = i18n("Enter username and password for ") + Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + ""; passwordDialog.introLabel->setText(introMessage); passwordDialog.introLabel->setWordWrap(true); @@ -123,8 +105,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox proxyDialog.iconLabel->setText(QString()); proxyDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); - QString introMessage = tr("Connect to proxy \"%1\" using:"); - introMessage = introMessage.arg(Qt::escape(proxy.hostName())); + QString introMessage = i18n("Connect to proxy ") + Qt::escape(proxy.hostName()) + i18n(" using:"); proxyDialog.introLabel->setText(introMessage); proxyDialog.introLabel->setWordWrap(true); @@ -144,8 +125,7 @@ void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QListurl().toString()).arg(errors), + i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n", QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (ret == QMessageBox::Yes) diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index d49c7fa4..06fc6efd 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -1,39 +1,21 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef NETWORKACCESSMANAGER_H #define NETWORKACCESSMANAGER_H diff --git a/src/searchlineedit.cpp b/src/searchlineedit.cpp index 97fdf726..16ba0ccd 100644 --- a/src/searchlineedit.cpp +++ b/src/searchlineedit.cpp @@ -1,53 +1,38 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// Local Includes #include "searchlineedit.h" -#include -#include -#include -#include -#include +// Qt Includes +#include +#include +#include +#include +#include + ClearButton::ClearButton(QWidget *parent) : QAbstractButton(parent) { setCursor(Qt::ArrowCursor); - setToolTip(tr("Clear")); + setToolTip( tr("Clear") ); setVisible(false); setFocusPolicy(Qt::NoFocus); } diff --git a/src/searchlineedit.h b/src/searchlineedit.h index 2f2a8362..d9f2aecb 100644 --- a/src/searchlineedit.h +++ b/src/searchlineedit.h @@ -1,47 +1,31 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef SEARCHLINEEDIT_H #define SEARCHLINEEDIT_H +// Local Includes #include "urllineedit.h" -#include -#include +// Qt Includes +#include +#include QT_BEGIN_NAMESPACE class QMenu; diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index f873ec6f..e775453b 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -1,39 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + #include "tabwidget.h" @@ -43,15 +27,15 @@ #include "urllineedit.h" #include "webview.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -87,32 +71,32 @@ void TabBar::selectTabAction() void TabBar::contextMenuRequested(const QPoint &position) { QMenu menu; - menu.addAction(tr("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); + menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); if (-1 != index) { - QAction *action = menu.addAction(tr("Clone Tab"), + QAction *action = menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); action->setData(index); menu.addSeparator(); - action = menu.addAction(tr("&Close Tab"), + action = menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); action->setData(index); - action = menu.addAction(tr("Close &Other Tabs"), + action = menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); action->setData(index); menu.addSeparator(); - action = menu.addAction(tr("Reload Tab"), + action = menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); } else { menu.addSeparator(); } - menu.addAction(tr("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); + menu.addAction(i18n("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); menu.exec(QCursor::pos()); } @@ -233,17 +217,17 @@ TabWidget::TabWidget(QWidget *parent) setTabBar(m_tabBar); // Actions - m_newTabAction = new QAction(QIcon(QLatin1String(":addtab.png")), tr("New &Tab"), this); + m_newTabAction = new QAction(KIcon("tab-new"), i18n("New &Tab"), this); m_newTabAction->setShortcuts(QKeySequence::AddTab); m_newTabAction->setIconVisibleInMenu(false); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); - m_closeTabAction = new QAction(QIcon(QLatin1String(":closetab.png")), tr("&Close Tab"), this); + m_closeTabAction = new QAction(KIcon("tab-close"), i18n("&Close Tab"), this); m_closeTabAction->setShortcuts(QKeySequence::Close); m_closeTabAction->setIconVisibleInMenu(false); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); - m_nextTabAction = new QAction(tr("Show Next Tab"), this); + m_nextTabAction = new QAction(i18n("Show Next Tab"), this); QList shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); @@ -252,7 +236,7 @@ TabWidget::TabWidget(QWidget *parent) m_nextTabAction->setShortcuts(shortcuts); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); - m_previousTabAction = new QAction(tr("Show Previous Tab"), this); + m_previousTabAction = new QAction(i18n("Show Previous Tab"), this); shortcuts.clear(); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); @@ -266,7 +250,7 @@ TabWidget::TabWidget(QWidget *parent) this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); - m_recentlyClosedTabsAction = new QAction(tr("Recently Closed Tabs"), this); + m_recentlyClosedTabsAction = new QAction(i18n("Recently Closed Tabs"), this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); @@ -465,7 +449,7 @@ WebView *TabWidget::newTab(bool makeCurrent) emptyWidget->setAutoFillBackground(true); disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - addTab(emptyWidget, tr("(Untitled)")); + addTab(emptyWidget, i18n("(Untitled)")); connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); return 0; @@ -496,7 +480,7 @@ WebView *TabWidget::newTab(bool makeCurrent) this, SIGNAL(statusBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); - addTab(webView, tr("(Untitled)")); + addTab(webView, i18n("(Untitled)")); if (makeCurrent) setCurrentWidget(webView); @@ -578,8 +562,8 @@ void TabWidget::closeTab(int index) if (tab->isModified()) { QMessageBox closeConfirmation(tab); closeConfirmation.setWindowFlags(Qt::Sheet); - closeConfirmation.setWindowTitle(tr("Do you really want to close this page?")); - closeConfirmation.setInformativeText(tr("You have modified this page and when closing it you would lose the modification.\n" + closeConfirmation.setWindowTitle(i18n("Do you really want to close this page?")); + closeConfirmation.setInformativeText(i18n("You have modified this page and when closing it you would lose the modification.\n" "Do you really want to close this page?\n")); closeConfirmation.setIcon(QMessageBox::Question); closeConfirmation.addButton(QMessageBox::Yes); diff --git a/src/tabwidget.h b/src/tabwidget.h index 1bdd56bf..89d87410 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -1,39 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + #ifndef TABWIDGET_H #define TABWIDGET_H diff --git a/src/toolbarsearch.cpp b/src/toolbarsearch.cpp index 16022fe0..26661386 100644 --- a/src/toolbarsearch.cpp +++ b/src/toolbarsearch.cpp @@ -1,51 +1,33 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// Local Includes #include "toolbarsearch.h" #include "autosaver.h" -#include -#include - -#include -#include -#include - -#include +// Qt Includes +#include +#include +#include +#include +#include +#include /* ToolbarSearch is a very basic search widget that also contains a small history. @@ -66,7 +48,7 @@ ToolbarSearch::ToolbarSearch(QWidget *parent) lineEdit()->setCompleter(completer); connect(lineEdit(), SIGNAL(returnPressed()), SLOT(searchNow())); - setInactiveText(tr("Google")); + setInactiveText("Google"); load(); } @@ -114,7 +96,7 @@ void ToolbarSearch::searchNow() url.addQueryItem(QLatin1String("q"), searchText); url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); - url.addQueryItem(QLatin1String("client"), QLatin1String("qtdemobrowser")); + url.addQueryItem(QLatin1String("client"), QLatin1String("reKonq")); emit search(url); } @@ -125,18 +107,18 @@ void ToolbarSearch::aboutToShowMenu() m->clear(); QStringList list = m_stringListModel->stringList(); if (list.isEmpty()) { - m->addAction(tr("No Recent Searches")); + m->addAction( tr("No Recent Searches") ); return; } - QAction *recent = m->addAction(tr("Recent Searches")); + QAction *recent = m->addAction( tr("Recent Searches") ); recent->setEnabled(false); for (int i = 0; i < list.count(); ++i) { QString text = list.at(i); m->addAction(text)->setData(text); } m->addSeparator(); - m->addAction(tr("Clear Recent Searches"), this, SLOT(clear())); + m->addAction( tr("Clear Recent Searches"), this, SLOT(clear())); } void ToolbarSearch::triggeredMenuAction(QAction *action) diff --git a/src/toolbarsearch.h b/src/toolbarsearch.h index 9ecbf183..a9a20a1d 100644 --- a/src/toolbarsearch.h +++ b/src/toolbarsearch.h @@ -1,39 +1,21 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef TOOLBARSEARCH_H #define TOOLBARSEARCH_H diff --git a/src/webview.cpp b/src/webview.cpp index 39cedd95..2d059194 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #include "browserapplication.h" #include "browsermainwindow.h" @@ -43,17 +26,17 @@ #include "tabwidget.h" #include "webview.h" -#include -#include -#include -#include - -#include +#include +#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include WebPage::WebPage(QObject *parent) : QWebPage(parent) @@ -142,10 +125,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) return; } - QFile file(QLatin1String(":/notfound.html")); + QString myfilestr = KStandardDirs::locate("data", "rekonq/htmls/notfound.html"); + QFile file( myfilestr ); bool isOpened = file.open(QIODevice::ReadOnly); Q_ASSERT(isOpened); - QString title = tr("Error loading page: %1").arg(reply->url().toString()); + QString title = i18n("Error loading page: ") + reply->url().toString(); QString html = QString(QLatin1String(file.readAll())) .arg(title) .arg(reply->errorString()) @@ -204,7 +188,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) if (!r.linkUrl().isEmpty()) { QMenu menu(this); menu.addAction(pageAction(QWebPage::OpenLinkInNewWindow)); - menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab())); + menu.addAction(i18n("Open in New Tab"), this, SLOT(openLinkInNewTab())); menu.addSeparator(); menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); // Add link to bookmarks... diff --git a/src/webview.h b/src/webview.h index 73c9dafb..ea955a71 100644 --- a/src/webview.h +++ b/src/webview.h @@ -1,44 +1,26 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef WEBVIEW_H #define WEBVIEW_H -#include +#include QT_BEGIN_NAMESPACE class QAuthenticator; diff --git a/src/xbel.cpp b/src/xbel.cpp index 3accd76d..788c6d03 100644 --- a/src/xbel.cpp +++ b/src/xbel.cpp @@ -1,43 +1,30 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ - +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// Local Includes #include "xbel.h" -#include +// KDE Includes +#include + +// Qt Includes +#include BookmarkNode::BookmarkNode(BookmarkNode::Type type, BookmarkNode *parent) : expanded(false) @@ -137,7 +124,7 @@ BookmarkNode *XbelReader::read(QIODevice *device) && (version.isEmpty() || version == QLatin1String("1.0"))) { readXBEL(root); } else { - raiseError(QObject::tr("The file is not an XBEL version 1.0 file.")); + raiseError( i18n("The file is not an XBEL version 1.0 file.") ); } } } @@ -235,7 +222,7 @@ void XbelReader::readBookmarkNode(BookmarkNode *parent) } } if (bookmark->title.isEmpty()) - bookmark->title = QObject::tr("Unknown title"); + bookmark->title = i18n("Unknown title"); } void XbelReader::skipUnknownElement() diff --git a/src/xbel.h b/src/xbel.h index fdacd1b9..972bbf17 100644 --- a/src/xbel.h +++ b/src/xbel.h @@ -1,39 +1,21 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef XBEL_H #define XBEL_H -- cgit v1.2.1 From 4a0acb308cfecde67af334f48a521c221c4aee1a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 7 Nov 2008 00:17:56 +0100 Subject: Setting right license --- src/autosaver.cpp | 55 +++--- src/autosaver.h | 55 +++--- src/bookmarks.cpp | 1 + src/bookmarks.h | 55 +++--- src/browser.icns | Bin 57624 -> 0 bytes src/browser.ico | Bin 287934 -> 0 bytes src/browser.pro | 87 ---------- src/browser.rc | 2 - src/browserapplication.cpp | 1 + src/browserapplication.h | 1 + src/browsermainwindow.cpp | 393 +++++++++++++++++++++---------------------- src/browsermainwindow.h | 30 ++-- src/cookiejar.cpp | 1 + src/cookiejar.h | 55 +++--- src/downloadmanager.cpp | 1 + src/downloadmanager.h | 1 + src/edittableview.cpp | 55 +++--- src/edittableview.h | 55 +++--- src/edittreeview.cpp | 55 +++--- src/edittreeview.h | 55 +++--- src/history.cpp | 1 + src/history.h | 1 + src/main.cpp | 1 + src/modelmenu.cpp | 55 +++--- src/modelmenu.h | 56 +++--- src/networkaccessmanager.cpp | 1 + src/networkaccessmanager.h | 1 + src/searchlineedit.cpp | 1 + src/searchlineedit.h | 1 + src/settings.cpp | 55 +++--- src/settings.h | 55 +++--- src/squeezelabel.cpp | 55 +++--- src/squeezelabel.h | 55 +++--- src/tabwidget.cpp | 1 + src/tabwidget.h | 1 + src/toolbarsearch.cpp | 1 + src/toolbarsearch.h | 1 + src/urllineedit.cpp | 55 +++--- src/urllineedit.h | 55 +++--- src/webview.cpp | 1 + src/webview.h | 1 + src/xbel.cpp | 2 + src/xbel.h | 1 + 43 files changed, 537 insertions(+), 878 deletions(-) delete mode 100644 src/browser.icns delete mode 100644 src/browser.ico delete mode 100644 src/browser.pro delete mode 100644 src/browser.rc diff --git a/src/autosaver.cpp b/src/autosaver.cpp index f8d088dd..4b83b65d 100644 --- a/src/autosaver.cpp +++ b/src/autosaver.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #include "autosaver.h" diff --git a/src/autosaver.h b/src/autosaver.h index 162b3b6c..d8004a9d 100644 --- a/src/autosaver.h +++ b/src/autosaver.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef AUTOSAVER_H #define AUTOSAVER_H diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 7f432ba9..6f87d3a4 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/bookmarks.h b/src/bookmarks.h index 768efd53..4ce3e49f 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef BOOKMARKS_H #define BOOKMARKS_H diff --git a/src/browser.icns b/src/browser.icns deleted file mode 100644 index 8cc82ba9..00000000 Binary files a/src/browser.icns and /dev/null differ diff --git a/src/browser.ico b/src/browser.ico deleted file mode 100644 index f15627a1..00000000 Binary files a/src/browser.ico and /dev/null differ diff --git a/src/browser.pro b/src/browser.pro deleted file mode 100644 index 38ef03b5..00000000 --- a/src/browser.pro +++ /dev/null @@ -1,87 +0,0 @@ -TEMPLATE = app -TARGET = browser -QT += webkit network - -CONFIG += qt warn_on -contains(QT_BUILD_PARTS, tools): CONFIG += uitools -else: DEFINES += QT_NO_UITOOLS - -FORMS += \ - addbookmarkdialog.ui \ - bookmarks.ui \ - cookies.ui \ - cookiesexceptions.ui \ - downloaditem.ui \ - downloads.ui \ - history.ui \ - passworddialog.ui \ - proxy.ui \ - settings.ui - -HEADERS += \ - autosaver.h \ - bookmarks.h \ - browserapplication.h \ - browsermainwindow.h \ - chasewidget.h \ - cookiejar.h \ - downloadmanager.h \ - edittableview.h \ - edittreeview.h \ - history.h \ - modelmenu.h \ - networkaccessmanager.h \ - searchlineedit.h \ - settings.h \ - squeezelabel.h \ - tabwidget.h \ - toolbarsearch.h \ - urllineedit.h \ - webview.h \ - xbel.h - -SOURCES += \ - autosaver.cpp \ - bookmarks.cpp \ - browserapplication.cpp \ - browsermainwindow.cpp \ - chasewidget.cpp \ - cookiejar.cpp \ - downloadmanager.cpp \ - edittableview.cpp \ - edittreeview.cpp \ - history.cpp \ - modelmenu.cpp \ - networkaccessmanager.cpp \ - searchlineedit.cpp \ - settings.cpp \ - squeezelabel.cpp \ - tabwidget.cpp \ - toolbarsearch.cpp \ - urllineedit.cpp \ - webview.cpp \ - xbel.cpp \ - main.cpp - -RESOURCES += data/data.qrc htmls/htmls.qrc - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -win32 { - RC_FILE = browser.rc -} - -mac { - ICON = browser.icns - QMAKE_INFO_PLIST = Info_mac.plist - TARGET = Browser -} - -# install -target.path = $$[QT_INSTALL_DEMOS]/browser -sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.plist *.icns *.ico *.rc *.pro *.html *.doc images htmls -sources.path = $$[QT_INSTALL_DEMOS]/browser -INSTALLS += target sources diff --git a/src/browser.rc b/src/browser.rc deleted file mode 100644 index 89a237ce..00000000 --- a/src/browser.rc +++ /dev/null @@ -1,2 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "browser.ico" - diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 6d4e08fa..71da13eb 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/browserapplication.h b/src/browserapplication.h index 801cdec5..c5b5c901 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 450f90b5..c67310ae 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * @@ -217,12 +218,12 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) void BrowserMainWindow::setupMenu() { - new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(slotSwapFocus())); - +// new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(slotSwapFocus())); +// // ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- - QMenu *fileMenu = menuBar()->addMenu( i18n("&File")); + KMenu *fileMenu = menuBar()->addMenu( i18n("&File") ); - fileMenu->addAction(i18n("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New); + fileMenu->addAction( i18n("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New); fileMenu->addAction(m_tabWidget->newTabAction()); fileMenu->addAction(i18n("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence::Open); fileMenu->addAction(i18n("Open &Location..."), this, SLOT(slotSelectLineEdit()), QKeySequence(Qt::ControlModifier + Qt::Key_L)); @@ -242,164 +243,160 @@ void BrowserMainWindow::setupMenu() action->setCheckable(true); fileMenu->addSeparator(); -#if defined(Q_WS_MAC) - fileMenu->addAction( i18n("&Quit"), BrowserApplication::instance(), SLOT(quitBrowser()), QKeySequence(Qt::CTRL | Qt::Key_Q)); -#else fileMenu->addAction( i18n("&Quit"), this, SLOT(close()), QKeySequence(Qt::CTRL | Qt::Key_Q)); -#endif - - // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- - QMenu *editMenu = menuBar()->addMenu(i18n("&Edit")); - - QAction *m_undo = editMenu->addAction(i18n("&Undo")); - m_undo->setShortcuts(QKeySequence::Undo); - m_tabWidget->addWebAction(m_undo, QWebPage::Undo); - - QAction *m_redo = editMenu->addAction(i18n("&Redo")); - m_redo->setShortcuts(QKeySequence::Redo); - m_tabWidget->addWebAction(m_redo, QWebPage::Redo); - - editMenu->addSeparator(); - - QAction *m_cut = editMenu->addAction(i18n("Cu&t")); - m_cut->setShortcuts(QKeySequence::Cut); - m_tabWidget->addWebAction(m_cut, QWebPage::Cut); - - QAction *m_copy = editMenu->addAction(i18n("&Copy")); - m_copy->setShortcuts(QKeySequence::Copy); - m_tabWidget->addWebAction(m_copy, QWebPage::Copy); - - QAction *m_paste = editMenu->addAction(i18n("&Paste")); - m_paste->setShortcuts(QKeySequence::Paste); - m_tabWidget->addWebAction(m_paste, QWebPage::Paste); - - editMenu->addSeparator(); - - QAction *m_find = editMenu->addAction(i18n("&Find")); - m_find->setShortcuts(QKeySequence::Find); - connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); - new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); - - QAction *m_findNext = editMenu->addAction( i18n("&Find Next")); - m_findNext->setShortcuts(QKeySequence::FindNext); - connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); - QAction *m_findPrevious = editMenu->addAction( i18n("&Find Previous")); - m_findPrevious->setShortcuts(QKeySequence::FindPrevious); - connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); - - editMenu->addSeparator(); - editMenu->addAction( i18n("&Preferences"), this, SLOT(slotPreferences()), i18n("Ctrl+,")); - - - // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- - QMenu *viewMenu = menuBar()->addMenu( i18n("&View") ); - - m_viewStatusbar = new KAction(this); - updateStatusbarActionText(true); - m_viewStatusbar->setShortcut( i18n("Ctrl+/") ); - connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); - viewMenu->addAction(m_viewStatusbar); - - viewMenu->addSeparator(); - - m_stop = viewMenu->addAction( i18n("&Stop") ); - QList shortcuts; - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); - shortcuts.append(Qt::Key_Escape); - m_stop->setShortcuts(shortcuts); - m_tabWidget->addWebAction(m_stop, QWebPage::Stop); - - m_reload = viewMenu->addAction( i18n("Reload Page") ); - m_reload->setShortcuts(QKeySequence::Refresh); - m_tabWidget->addWebAction(m_reload, QWebPage::Reload); - - viewMenu->addAction( i18n("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); - viewMenu->addAction( i18n("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); - viewMenu->addAction( i18n("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); - - viewMenu->addSeparator(); - viewMenu->addAction( i18n("Page S&ource"), this, SLOT(slotViewPageSource()), i18n("Ctrl+Alt+U")); - QAction *a = viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); - a->setCheckable(true); - - - // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- - HistoryMenu *historyMenu = new HistoryMenu(this); - connect(historyMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); - connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); - historyMenu->setTitle( i18n("Hi&story") ); - menuBar()->addMenu(historyMenu); - QList historyActions; - - m_historyBack = new QAction( i18n("Back"), this); - m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); - m_historyBack->setShortcuts(QKeySequence::Back); - m_historyBack->setIconVisibleInMenu(false); - - m_historyForward = new QAction( i18n("Forward"), this); - m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); - m_historyForward->setShortcuts(QKeySequence::Forward); - m_historyForward->setIconVisibleInMenu(false); - - QAction *m_historyHome = new QAction( i18n("Home"), this); - connect(m_historyHome, SIGNAL(triggered()), this, SLOT(slotHome())); - m_historyHome->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H)); - - m_restoreLastSession = new QAction( i18n("Restore Last Session"), this); - connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); - m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); - - historyActions.append(m_historyBack); - historyActions.append(m_historyForward); - historyActions.append(m_historyHome); - historyActions.append(m_tabWidget->recentlyClosedTabsAction()); - historyActions.append(m_restoreLastSession); - historyMenu->setInitialActions(historyActions); - - // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- - BookmarksMenu *bookmarksMenu = new BookmarksMenu(this); - connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); - connect(bookmarksMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); - bookmarksMenu->setTitle(i18n("&Bookmarks")); - menuBar()->addMenu(bookmarksMenu); - - // FIXME -// BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); -// bookmarksMenu->addAction(i18n("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); -// bookmarksMenu->addAction(i18n("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); -// bookmarksMenu->addSeparator(); - - QList bookmarksActions; - - QAction *showAllBookmarksAction = new QAction(i18n("Show All Bookmarks"), this); - connect(showAllBookmarksAction, SIGNAL(triggered()), this, SLOT(slotShowBookmarksDialog())); - m_addBookmark = new QAction( KIcon("bookmark-new"), i18n("Add Bookmark..."), this); - m_addBookmark->setIconVisibleInMenu(false); - - connect(m_addBookmark, SIGNAL(triggered()), this, SLOT(slotAddBookmark())); - m_addBookmark->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D)); - - bookmarksActions.append(showAllBookmarksAction); - bookmarksActions.append(m_addBookmark); - bookmarksMenu->setInitialActions(bookmarksActions); - - // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- - m_windowMenu = menuBar()->addMenu( i18n("&Window")); - connect(m_windowMenu, SIGNAL(aboutToShow()), - this, SLOT(slotAboutToShowWindowMenu())); - slotAboutToShowWindowMenu(); - - QMenu *toolsMenu = menuBar()->addMenu( i18n("&Tools")); - toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); -#ifndef Q_CC_MINGW - a = toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); - a->setCheckable(true); -#endif - - QMenu *helpMenu = menuBar()->addMenu( i18n("&Help")); - helpMenu->addAction( i18n("About &Qt"), qApp, SLOT(aboutQt())); - helpMenu->addAction( i18n("About &reKonq"), this, SLOT(slotAboutApplication())); +// // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- +// QMenu *editMenu = menuBar()->addMenu(i18n("&Edit")); +// +// QAction *m_undo = editMenu->addAction(i18n("&Undo")); +// m_undo->setShortcuts(QKeySequence::Undo); +// m_tabWidget->addWebAction(m_undo, QWebPage::Undo); +// +// QAction *m_redo = editMenu->addAction(i18n("&Redo")); +// m_redo->setShortcuts(QKeySequence::Redo); +// m_tabWidget->addWebAction(m_redo, QWebPage::Redo); +// +// editMenu->addSeparator(); +// +// QAction *m_cut = editMenu->addAction(i18n("Cu&t")); +// m_cut->setShortcuts(QKeySequence::Cut); +// m_tabWidget->addWebAction(m_cut, QWebPage::Cut); +// +// QAction *m_copy = editMenu->addAction(i18n("&Copy")); +// m_copy->setShortcuts(QKeySequence::Copy); +// m_tabWidget->addWebAction(m_copy, QWebPage::Copy); +// +// QAction *m_paste = editMenu->addAction(i18n("&Paste")); +// m_paste->setShortcuts(QKeySequence::Paste); +// m_tabWidget->addWebAction(m_paste, QWebPage::Paste); +// +// editMenu->addSeparator(); +// +// QAction *m_find = editMenu->addAction(i18n("&Find")); +// m_find->setShortcuts(QKeySequence::Find); +// connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); +// new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); +// +// QAction *m_findNext = editMenu->addAction( i18n("&Find Next")); +// m_findNext->setShortcuts(QKeySequence::FindNext); +// connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); +// +// QAction *m_findPrevious = editMenu->addAction( i18n("&Find Previous")); +// m_findPrevious->setShortcuts(QKeySequence::FindPrevious); +// connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); +// +// editMenu->addSeparator(); +// editMenu->addAction( i18n("&Preferences"), this, SLOT(slotPreferences()), i18n("Ctrl+,")); +// +// +// // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- +// QMenu *viewMenu = menuBar()->addMenu( i18n("&View") ); +// +// m_viewStatusbar = new KAction(this); +// updateStatusbarActionText(true); +// m_viewStatusbar->setShortcut( i18n("Ctrl+/") ); +// connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); +// viewMenu->addAction(m_viewStatusbar); +// +// viewMenu->addSeparator(); +// +// m_stop = viewMenu->addAction( i18n("&Stop") ); +// QList shortcuts; +// shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); +// shortcuts.append(Qt::Key_Escape); +// m_stop->setShortcuts(shortcuts); +// m_tabWidget->addWebAction(m_stop, QWebPage::Stop); +// +// m_reload = viewMenu->addAction( i18n("Reload Page") ); +// m_reload->setShortcuts(QKeySequence::Refresh); +// m_tabWidget->addWebAction(m_reload, QWebPage::Reload); +// +// viewMenu->addAction( i18n("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); +// viewMenu->addAction( i18n("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); +// viewMenu->addAction( i18n("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); +// +// viewMenu->addSeparator(); +// viewMenu->addAction( i18n("Page S&ource"), this, SLOT(slotViewPageSource()), i18n("Ctrl+Alt+U")); +// QAction *a = viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); +// a->setCheckable(true); +// +// +// // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- +// HistoryMenu *historyMenu = new HistoryMenu(this); +// connect(historyMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); +// connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); +// historyMenu->setTitle( i18n("Hi&story") ); +// menuBar()->addMenu(historyMenu); +// QList historyActions; +// +// m_historyBack = new QAction( i18n("Back"), this); +// m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); +// m_historyBack->setShortcuts(QKeySequence::Back); +// m_historyBack->setIconVisibleInMenu(false); +// +// m_historyForward = new QAction( i18n("Forward"), this); +// m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); +// m_historyForward->setShortcuts(QKeySequence::Forward); +// m_historyForward->setIconVisibleInMenu(false); +// +// QAction *m_historyHome = new QAction( i18n("Home"), this); +// connect(m_historyHome, SIGNAL(triggered()), this, SLOT(slotHome())); +// m_historyHome->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H)); +// +// m_restoreLastSession = new QAction( i18n("Restore Last Session"), this); +// connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); +// m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); +// +// historyActions.append(m_historyBack); +// historyActions.append(m_historyForward); +// historyActions.append(m_historyHome); +// historyActions.append(m_tabWidget->recentlyClosedTabsAction()); +// historyActions.append(m_restoreLastSession); +// historyMenu->setInitialActions(historyActions); +// +// // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- +// BookmarksMenu *bookmarksMenu = new BookmarksMenu(this); +// connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); +// connect(bookmarksMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); +// bookmarksMenu->setTitle(i18n("&Bookmarks")); +// menuBar()->addMenu(bookmarksMenu); +// +// // FIXME +// // BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); +// // bookmarksMenu->addAction(i18n("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); +// // bookmarksMenu->addAction(i18n("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); +// // bookmarksMenu->addSeparator(); +// +// QList bookmarksActions; +// +// QAction *showAllBookmarksAction = new QAction(i18n("Show All Bookmarks"), this); +// connect(showAllBookmarksAction, SIGNAL(triggered()), this, SLOT(slotShowBookmarksDialog())); +// m_addBookmark = new QAction( KIcon("bookmark-new"), i18n("Add Bookmark..."), this); +// m_addBookmark->setIconVisibleInMenu(false); +// +// connect(m_addBookmark, SIGNAL(triggered()), this, SLOT(slotAddBookmark())); +// m_addBookmark->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D)); +// +// bookmarksActions.append(showAllBookmarksAction); +// bookmarksActions.append(m_addBookmark); +// bookmarksMenu->setInitialActions(bookmarksActions); +// +// // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- +// m_windowMenu = menuBar()->addMenu( i18n("&Window")); +// connect(m_windowMenu, SIGNAL(aboutToShow()), +// this, SLOT(slotAboutToShowWindowMenu())); +// slotAboutToShowWindowMenu(); +// +// QMenu *toolsMenu = menuBar()->addMenu( i18n("&Tools")); +// toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); +// #ifndef Q_CC_MINGW +// a = toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); +// a->setCheckable(true); +// #endif +// +// QMenu *helpMenu = menuBar()->addMenu( i18n("&Help")); +// helpMenu->addAction( i18n("About &Qt"), qApp, SLOT(aboutQt())); +// helpMenu->addAction( i18n("About &reKonq"), this, SLOT(slotAboutApplication())); } @@ -408,44 +405,44 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { - setUnifiedTitleAndToolBarOnMac(true); - - m_navigationBar = addToolBar(i18n("Navigation")); - connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); - - m_historyBack->setIcon( KIcon("go-previous") ); - m_historyBackMenu = new QMenu(this); - m_historyBack->setMenu(m_historyBackMenu); - connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); - connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - m_navigationBar->addAction(m_historyBack); - - m_historyForward->setIcon( KIcon("go-next") ); - m_historyForwardMenu = new QMenu(this); - connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowForwardMenu())); - connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - m_historyForward->setMenu(m_historyForwardMenu); - m_navigationBar->addAction(m_historyForward); - - m_stopReload = new QAction(this); - m_reloadIcon = KIcon( "view-refresh" ); - m_stopReload->setIcon(m_reloadIcon); - m_navigationBar->addAction(m_stopReload); - - m_goHome = new QAction(this); - m_goHome->setIcon( KIcon( "go-home" ) ); - m_navigationBar->addAction(m_goHome); - connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); - - m_navigationBar->addWidget(m_tabWidget->lineEditStack()); - - m_toolbarSearch = new ToolbarSearch(m_navigationBar); - m_navigationBar->addWidget(m_toolbarSearch); - - // fixing toolbar movements - m_navigationBar->setFloatable( false ); - - connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); +// setUnifiedTitleAndToolBarOnMac(true); +// +// m_navigationBar = addToolBar(i18n("Navigation")); +// connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); +// +// m_historyBack->setIcon( KIcon("go-previous") ); +// m_historyBackMenu = new QMenu(this); +// m_historyBack->setMenu(m_historyBackMenu); +// connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); +// connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); +// m_navigationBar->addAction(m_historyBack); +// +// m_historyForward->setIcon( KIcon("go-next") ); +// m_historyForwardMenu = new QMenu(this); +// connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowForwardMenu())); +// connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); +// m_historyForward->setMenu(m_historyForwardMenu); +// m_navigationBar->addAction(m_historyForward); +// +// m_stopReload = new QAction(this); +// m_reloadIcon = KIcon( "view-refresh" ); +// m_stopReload->setIcon(m_reloadIcon); +// m_navigationBar->addAction(m_stopReload); +// +// m_goHome = new QAction(this); +// m_goHome->setIcon( KIcon( "go-home" ) ); +// m_navigationBar->addAction(m_goHome); +// connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); +// +// m_navigationBar->addWidget(m_tabWidget->lineEditStack()); +// +// m_toolbarSearch = new ToolbarSearch(m_navigationBar); +// m_navigationBar->addWidget(m_toolbarSearch); +// +// // fixing toolbar movements +// m_navigationBar->setFloatable( false ); +// +// connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); } diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index aba3d61d..54c590e3 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * @@ -30,7 +31,6 @@ #include class AutoSaver; -// class ChaseWidget; class QWebFrame; class TabWidget; class ToolbarSearch; @@ -114,24 +114,24 @@ private: void updateStatusbarActionText(bool visible); private: - QToolBar *m_navigationBar; + KToolBar *m_navigationBar; ToolbarSearch *m_toolbarSearch; TabWidget *m_tabWidget; AutoSaver *m_autoSaver; - QAction *m_historyBack; - QMenu *m_historyBackMenu; - QAction *m_historyForward; - QMenu *m_historyForwardMenu; - QMenu *m_windowMenu; - - QAction *m_stop; - QAction *m_reload; - QAction *m_stopReload; - QAction *m_goHome; - QAction *m_viewStatusbar; - QAction *m_restoreLastSession; - QAction *m_addBookmark; + KAction *m_historyBack; + KMenu *m_historyBackMenu; + KAction *m_historyForward; + KMenu *m_historyForwardMenu; + KMenu *m_windowMenu; + + KAction *m_stop; + KAction *m_reload; + KAction *m_stopReload; + KAction *m_goHome; + KAction *m_viewStatusbar; + KAction *m_restoreLastSession; + KAction *m_addBookmark; KIcon m_reloadIcon; KIcon m_stopIcon; diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index 098506c9..8e985abc 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/cookiejar.h b/src/cookiejar.h index 50d007f0..fbc89946 100644 --- a/src/cookiejar.h +++ b/src/cookiejar.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef COOKIEJAR_H #define COOKIEJAR_H diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index e3254cba..7584f36a 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/downloadmanager.h b/src/downloadmanager.h index af33ea12..89981641 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/edittableview.cpp b/src/edittableview.cpp index d47ac78b..5f60721a 100644 --- a/src/edittableview.cpp +++ b/src/edittableview.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #include "edittableview.h" #include diff --git a/src/edittableview.h b/src/edittableview.h index f22c3ce9..48d60d2a 100644 --- a/src/edittableview.h +++ b/src/edittableview.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef EDITTABLEVIEW_H #define EDITTABLEVIEW_H diff --git a/src/edittreeview.cpp b/src/edittreeview.cpp index 5e55fd16..e01843f8 100644 --- a/src/edittreeview.cpp +++ b/src/edittreeview.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #include "edittreeview.h" diff --git a/src/edittreeview.h b/src/edittreeview.h index 1341ad62..b4a46b6f 100644 --- a/src/edittreeview.h +++ b/src/edittreeview.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef EDITTREEVIEW_H #define EDITTREEVIEW_H diff --git a/src/history.cpp b/src/history.cpp index 985a03ac..ea322b65 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/history.h b/src/history.h index 1a4a0743..80b9f517 100644 --- a/src/history.h +++ b/src/history.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/main.cpp b/src/main.cpp index d99226cf..304c2301 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp index 3a8fb0cd..3f543a1f 100644 --- a/src/modelmenu.cpp +++ b/src/modelmenu.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #include "modelmenu.h" diff --git a/src/modelmenu.h b/src/modelmenu.h index 81928256..d539d6bf 100644 --- a/src/modelmenu.h +++ b/src/modelmenu.h @@ -1,39 +1,23 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + #ifndef MODELMENU_H #define MODELMENU_H diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index f09a39ab..01ab06ce 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index 06fc6efd..45ef1b0d 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/searchlineedit.cpp b/src/searchlineedit.cpp index 16ba0ccd..620b3991 100644 --- a/src/searchlineedit.cpp +++ b/src/searchlineedit.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/searchlineedit.h b/src/searchlineedit.h index d9f2aecb..f7bbeb39 100644 --- a/src/searchlineedit.h +++ b/src/searchlineedit.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/settings.cpp b/src/settings.cpp index a3a85ee1..9aa2963d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #include "settings.h" diff --git a/src/settings.h b/src/settings.h index dfd8dd15..fbedaf4e 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef SETTINGS_H #define SETTINGS_H diff --git a/src/squeezelabel.cpp b/src/squeezelabel.cpp index f8687ca7..334219df 100644 --- a/src/squeezelabel.cpp +++ b/src/squeezelabel.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #include "squeezelabel.h" diff --git a/src/squeezelabel.h b/src/squeezelabel.h index 8dd996ef..7baee5f5 100644 --- a/src/squeezelabel.h +++ b/src/squeezelabel.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef SQUEEZELABEL_H #define SQUEEZELABEL_H diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index e775453b..6c340793 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/tabwidget.h b/src/tabwidget.h index 89d87410..15db1349 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/toolbarsearch.cpp b/src/toolbarsearch.cpp index 26661386..4fd3aa51 100644 --- a/src/toolbarsearch.cpp +++ b/src/toolbarsearch.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/toolbarsearch.h b/src/toolbarsearch.h index a9a20a1d..81f06180 100644 --- a/src/toolbarsearch.h +++ b/src/toolbarsearch.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/urllineedit.cpp b/src/urllineedit.cpp index 47900c04..bd48bb03 100644 --- a/src/urllineedit.cpp +++ b/src/urllineedit.cpp @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #include "urllineedit.h" diff --git a/src/urllineedit.h b/src/urllineedit.h index 283ff48e..726a2b2b 100644 --- a/src/urllineedit.h +++ b/src/urllineedit.h @@ -1,39 +1,22 @@ -/**************************************************************************** -** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the demonstration applications of the Qt Toolkit. -** -** Commercial Usage -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License versions 2.0 or 3.0 as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information -** to ensure GNU General Public Licensing requirements will be met: -** http://www.fsf.org/licensing/licenses/info/GPLv2.html and -** http://www.gnu.org/copyleft/gpl.html. In addition, as a special -** exception, Nokia gives you certain additional rights. These rights -** are described in the Nokia Qt GPL Exception version 1.3, included in -** the file GPL_EXCEPTION.txt in this package. -** -** Qt for Windows(R) Licensees -** As a special exception, Nokia, as the sole copyright holder for Qt -** Designer, grants users of the Qt/Eclipse Integration plug-in the -** right for the Qt/Eclipse Integration to link to functionality -** provided by Qt Designer and its related libraries. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** -****************************************************************************/ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ #ifndef URLLINEEDIT_H #define URLLINEEDIT_H diff --git a/src/webview.cpp b/src/webview.cpp index 2d059194..612a8a34 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/webview.h b/src/webview.h index ea955a71..14fbc8aa 100644 --- a/src/webview.h +++ b/src/webview.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * diff --git a/src/xbel.cpp b/src/xbel.cpp index 788c6d03..13a91ccb 100644 --- a/src/xbel.cpp +++ b/src/xbel.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * @@ -26,6 +27,7 @@ // Qt Includes #include + BookmarkNode::BookmarkNode(BookmarkNode::Type type, BookmarkNode *parent) : expanded(false) , m_parent(parent) diff --git a/src/xbel.h b/src/xbel.h index 972bbf17..b636a437 100644 --- a/src/xbel.h +++ b/src/xbel.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * -- cgit v1.2.1 From f6af24273de66c1f36dcd6ddcd97d45ed7e6f474 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 8 Nov 2008 12:05:58 +0100 Subject: Ported menubar to KDE --- src/browserapplication.cpp | 69 +----------- src/browserapplication.h | 8 -- src/browsermainwindow.cpp | 261 ++++++++++++++++++++++----------------------- src/browsermainwindow.h | 5 +- src/tabwidget.cpp | 4 +- 5 files changed, 138 insertions(+), 209 deletions(-) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 71da13eb..2a487143 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -74,18 +74,15 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server return; } -#if defined(Q_WS_MAC) - KApplication::setQuitOnLastWindowClosed(false); -#else KApplication::setQuitOnLastWindowClosed(true); -#endif m_localServer = new QLocalServer(this); - connect(m_localServer, SIGNAL(newConnection()), - this, SLOT(newLocalSocketConnection())); - if (!m_localServer->listen(serverName)) { + connect(m_localServer, SIGNAL(newConnection()), this, SLOT(newLocalSocketConnection())); + if (!m_localServer->listen(serverName)) + { if (m_localServer->serverError() == QAbstractSocket::AddressInUseError - && QFile::exists(m_localServer->serverName())) { + && QFile::exists(m_localServer->serverName())) + { QFile::remove(m_localServer->serverName()); m_localServer->listen(serverName); } @@ -101,11 +98,6 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server m_lastSession = settings.value(QLatin1String("lastSession")).toByteArray(); settings.endGroup(); -#if defined(Q_WS_MAC) - connect(this, SIGNAL(lastWindowClosed()), - this, SLOT(lastWindowClosed())); -#endif - QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -141,31 +133,6 @@ BrowserApplication *BrowserApplication::instance() -#if defined(Q_WS_MAC) -#include -void BrowserApplication::quitBrowser() -{ - clean(); - int tabCount = 0; - for (int i = 0; i < m_mainWindows.count(); ++i) { - tabCount =+ m_mainWindows.at(i)->tabWidget()->count(); - } - - if (tabCount > 1) { - int ret = QMessageBox::warning(mainWindow(), QString(), - i18n("There are ") + QString( m_mainWindows.count() ) + i18n(" windows and ") + QString(tabCount) + i18n("tabs open\n"), - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (ret == QMessageBox::No) - return; - } - - exit(0); -} -#endif - - - /*! Any actions that can be delayed until the window is visible @@ -326,32 +293,6 @@ void BrowserApplication::installTranslator(const QString &name) KApplication::installTranslator(translator); } -#if defined(Q_WS_MAC) -bool BrowserApplication::event(QEvent* event) -{ - switch (event->type()) { - case QEvent::ApplicationActivate: { - clean(); - if (!m_mainWindows.isEmpty()) { - BrowserMainWindow *mw = mainWindow(); - if (mw && !mw->isMinimized()) { - mainWindow()->show(); - } - return true; - } - } - case QEvent::FileOpen: - if (!m_mainWindows.isEmpty()) { - mainWindow()->loadPage(static_cast(event)->file()); - return true; - } - default: - break; - } - return KApplication::event(event); -} -#endif - void BrowserApplication::openUrl(const QUrl &url) diff --git a/src/browserapplication.h b/src/browserapplication.h index c5b5c901..95b93218 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -64,17 +64,9 @@ public: static NetworkAccessManager *networkAccessManager(); static BookmarksManager *bookmarksManager(); -#if defined(Q_WS_MAC) - bool event(QEvent *event); -#endif - public slots: BrowserMainWindow *newMainWindow(); void restoreLastSession(); -#if defined(Q_WS_MAC) - void lastWindowClosed(); - void quitBrowser(); -#endif private slots: void postLaunch(); diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index c67310ae..49b357c0 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -35,6 +35,10 @@ #include #include #include +#include +#include +#include + #include #include @@ -72,11 +76,7 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) QVBoxLayout *layout = new QVBoxLayout; layout->setSpacing(0); layout->setMargin(0); -#if defined(Q_WS_MAC) - layout->addWidget(new QWidget); // <- OS X tab widget style bug -#else addToolBarBreak(); -#endif layout->addWidget(m_tabWidget); centralWidget->setLayout(layout); setCentralWidget(centralWidget); @@ -91,19 +91,15 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); - connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), m_navigationBar, SLOT(setVisible(bool))); -#if defined(Q_WS_MAC) - connect(m_tabWidget, SIGNAL(lastTabClosed()), this, SLOT(close())); -#else +// connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), m_navigationBar, SLOT(setVisible(bool))); connect(m_tabWidget, SIGNAL(lastTabClosed()), m_tabWidget, SLOT(newTab())); -#endif slotUpdateWindowTitle(); loadDefaultState(); m_tabWidget->newTab(); int size = m_tabWidget->lineEditStack()->sizeHint().height(); - m_navigationBar->setIconSize(QSize(size, size)); +// m_navigationBar->setIconSize(QSize(size, size)); // FIXME re-enable me } @@ -118,11 +114,11 @@ BrowserMainWindow::~BrowserMainWindow() void BrowserMainWindow::loadDefaultState() { - QSettings settings; - settings.beginGroup(QLatin1String("BrowserMainWindow")); - QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); - restoreState(data); - settings.endGroup(); +// QSettings settings; +// settings.beginGroup(QLatin1String("BrowserMainWindow")); +// QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); +// // restoreState(data); // FIXME re-enable me! +// settings.endGroup(); } @@ -218,110 +214,108 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) void BrowserMainWindow::setupMenu() { -// new QShortcut(QKeySequence(Qt::Key_F6), this, SLOT(slotSwapFocus())); -// // ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- - KMenu *fileMenu = menuBar()->addMenu( i18n("&File") ); + KMenu *fileMenu = (KMenu *) menuBar()->addMenu( i18n("&File") ); - fileMenu->addAction( i18n("&New Window"), this, SLOT(slotFileNew()), QKeySequence::New); - fileMenu->addAction(m_tabWidget->newTabAction()); - fileMenu->addAction(i18n("&Open File..."), this, SLOT(slotFileOpen()), QKeySequence::Open); - fileMenu->addAction(i18n("Open &Location..."), this, SLOT(slotSelectLineEdit()), QKeySequence(Qt::ControlModifier + Qt::Key_L)); + fileMenu->addAction( KStandardAction::openNew(this, SLOT( slotFileNew() ) , this ) ); + fileMenu->addAction( KStandardAction::open( this, SLOT( slotFileOpen() ), this ) ); + fileMenu->addAction( i18n("Open Location"), this, SLOT( slotSelectLineEdit() ) ); fileMenu->addSeparator(); - fileMenu->addAction(m_tabWidget->closeTabAction()); + fileMenu->addAction( m_tabWidget->closeTabAction() ); fileMenu->addSeparator(); - fileMenu->addAction(i18n("&Save As..."), this, SLOT(slotFileSaveAs()), QKeySequence(QKeySequence::Save)); + fileMenu->addAction( KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), this ) ); fileMenu->addSeparator(); - fileMenu->addAction(i18n("P&rint Preview..."), this, SLOT(slotFilePrintPreview())); - fileMenu->addAction(i18n("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print); + fileMenu->addAction( KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), this ) ); + fileMenu->addAction( KStandardAction::print( this, SLOT(slotFilePrint()), this) ); fileMenu->addSeparator(); - QAction *action = fileMenu->addAction(i18n("Private &Browsing..."), this, SLOT(slotPrivateBrowsing())); + QAction *action = fileMenu->addAction( i18n("Private &Browsing..."), this, SLOT( slotPrivateBrowsing() ) ); action->setCheckable(true); fileMenu->addSeparator(); - fileMenu->addAction( i18n("&Quit"), this, SLOT(close()), QKeySequence(Qt::CTRL | Qt::Key_Q)); + fileMenu->addAction( KStandardAction::close( this , SLOT( close() ), this ) ); -// // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- -// QMenu *editMenu = menuBar()->addMenu(i18n("&Edit")); -// -// QAction *m_undo = editMenu->addAction(i18n("&Undo")); -// m_undo->setShortcuts(QKeySequence::Undo); -// m_tabWidget->addWebAction(m_undo, QWebPage::Undo); -// -// QAction *m_redo = editMenu->addAction(i18n("&Redo")); -// m_redo->setShortcuts(QKeySequence::Redo); -// m_tabWidget->addWebAction(m_redo, QWebPage::Redo); -// -// editMenu->addSeparator(); -// -// QAction *m_cut = editMenu->addAction(i18n("Cu&t")); -// m_cut->setShortcuts(QKeySequence::Cut); -// m_tabWidget->addWebAction(m_cut, QWebPage::Cut); -// -// QAction *m_copy = editMenu->addAction(i18n("&Copy")); -// m_copy->setShortcuts(QKeySequence::Copy); -// m_tabWidget->addWebAction(m_copy, QWebPage::Copy); -// -// QAction *m_paste = editMenu->addAction(i18n("&Paste")); -// m_paste->setShortcuts(QKeySequence::Paste); -// m_tabWidget->addWebAction(m_paste, QWebPage::Paste); -// -// editMenu->addSeparator(); -// -// QAction *m_find = editMenu->addAction(i18n("&Find")); -// m_find->setShortcuts(QKeySequence::Find); -// connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); -// new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); -// -// QAction *m_findNext = editMenu->addAction( i18n("&Find Next")); -// m_findNext->setShortcuts(QKeySequence::FindNext); -// connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); -// -// QAction *m_findPrevious = editMenu->addAction( i18n("&Find Previous")); -// m_findPrevious->setShortcuts(QKeySequence::FindPrevious); -// connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); -// -// editMenu->addSeparator(); -// editMenu->addAction( i18n("&Preferences"), this, SLOT(slotPreferences()), i18n("Ctrl+,")); -// -// -// // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- -// QMenu *viewMenu = menuBar()->addMenu( i18n("&View") ); -// -// m_viewStatusbar = new KAction(this); -// updateStatusbarActionText(true); -// m_viewStatusbar->setShortcut( i18n("Ctrl+/") ); -// connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); -// viewMenu->addAction(m_viewStatusbar); -// -// viewMenu->addSeparator(); -// -// m_stop = viewMenu->addAction( i18n("&Stop") ); -// QList shortcuts; -// shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); -// shortcuts.append(Qt::Key_Escape); -// m_stop->setShortcuts(shortcuts); -// m_tabWidget->addWebAction(m_stop, QWebPage::Stop); -// -// m_reload = viewMenu->addAction( i18n("Reload Page") ); -// m_reload->setShortcuts(QKeySequence::Refresh); -// m_tabWidget->addWebAction(m_reload, QWebPage::Reload); -// -// viewMenu->addAction( i18n("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); -// viewMenu->addAction( i18n("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); -// viewMenu->addAction( i18n("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); -// -// viewMenu->addSeparator(); -// viewMenu->addAction( i18n("Page S&ource"), this, SLOT(slotViewPageSource()), i18n("Ctrl+Alt+U")); -// QAction *a = viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); -// a->setCheckable(true); -// -// -// // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- + // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- + KMenu *editMenu = (KMenu *) menuBar()->addMenu( i18n("&Edit") ); + + QAction *m_undo = editMenu->addAction(i18n("&Undo")); + m_undo->setShortcuts(QKeySequence::Undo); + m_tabWidget->addWebAction(m_undo, QWebPage::Undo); + + QAction *m_redo = editMenu->addAction(i18n("&Redo")); + m_redo->setShortcuts(QKeySequence::Redo); + m_tabWidget->addWebAction(m_redo, QWebPage::Redo); + + editMenu->addSeparator(); + + QAction *m_cut = editMenu->addAction(i18n("Cu&t")); + m_cut->setShortcuts(QKeySequence::Cut); + m_tabWidget->addWebAction(m_cut, QWebPage::Cut); + + QAction *m_copy = editMenu->addAction(i18n("&Copy")); + m_copy->setShortcuts(QKeySequence::Copy); + m_tabWidget->addWebAction(m_copy, QWebPage::Copy); + + QAction *m_paste = editMenu->addAction(i18n("&Paste")); + m_paste->setShortcuts(QKeySequence::Paste); + m_tabWidget->addWebAction(m_paste, QWebPage::Paste); + + editMenu->addSeparator(); + + // FIXME port FIND system to KDE + QAction *m_find = editMenu->addAction(i18n("&Find")); + m_find->setShortcuts(QKeySequence::Find); + connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); + new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); + + QAction *m_findNext = editMenu->addAction( i18n("&Find Next")); + m_findNext->setShortcuts(QKeySequence::FindNext); + connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); + + QAction *m_findPrevious = editMenu->addAction( i18n("&Find Previous")); + m_findPrevious->setShortcuts(QKeySequence::FindPrevious); + connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); + + editMenu->addSeparator(); + + editMenu->addAction( i18n("&Preferences"), this, SLOT(slotPreferences()), i18n("Ctrl+,")); + + + // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- + KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); + + m_viewStatusbar = new KAction(this); + updateStatusbarActionText(true); + m_viewStatusbar->setShortcut( i18n("Ctrl+/") ); + connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); + viewMenu->addAction(m_viewStatusbar); + + viewMenu->addSeparator(); + + m_stop = viewMenu->addAction( i18n("&Stop") ); + QList shortcuts; + shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); + shortcuts.append(Qt::Key_Escape); + m_stop->setShortcuts(shortcuts); + m_tabWidget->addWebAction(m_stop, QWebPage::Stop); + + m_reload = viewMenu->addAction( i18n("Reload Page") ); + m_reload->setShortcuts(QKeySequence::Refresh); + m_tabWidget->addWebAction(m_reload, QWebPage::Reload); + + viewMenu->addAction( i18n("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); + viewMenu->addAction( i18n("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); + viewMenu->addAction( i18n("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); + + viewMenu->addSeparator(); + viewMenu->addAction( i18n("Page S&ource"), this, SLOT(slotViewPageSource()), i18n("Ctrl+Alt+U")); + action = viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); + action->setCheckable(true); + + // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- // HistoryMenu *historyMenu = new HistoryMenu(this); // connect(historyMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); // connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); @@ -354,7 +348,9 @@ void BrowserMainWindow::setupMenu() // historyActions.append(m_restoreLastSession); // historyMenu->setInitialActions(historyActions); // -// // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- + + + // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- // BookmarksMenu *bookmarksMenu = new BookmarksMenu(this); // connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); // connect(bookmarksMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); @@ -381,22 +377,23 @@ void BrowserMainWindow::setupMenu() // bookmarksActions.append(m_addBookmark); // bookmarksMenu->setInitialActions(bookmarksActions); // -// // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- -// m_windowMenu = menuBar()->addMenu( i18n("&Window")); -// connect(m_windowMenu, SIGNAL(aboutToShow()), -// this, SLOT(slotAboutToShowWindowMenu())); -// slotAboutToShowWindowMenu(); -// -// QMenu *toolsMenu = menuBar()->addMenu( i18n("&Tools")); -// toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); -// #ifndef Q_CC_MINGW -// a = toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); -// a->setCheckable(true); -// #endif -// -// QMenu *helpMenu = menuBar()->addMenu( i18n("&Help")); -// helpMenu->addAction( i18n("About &Qt"), qApp, SLOT(aboutQt())); -// helpMenu->addAction( i18n("About &reKonq"), this, SLOT(slotAboutApplication())); + + // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- + m_windowMenu = (KMenu *) menuBar()->addMenu( i18n("&Window") ); + + connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowWindowMenu())); + slotAboutToShowWindowMenu(); + + // ------------------------------------------------------------- TOOLS ------------------------------------------------------------------------------------------------------ + KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); + + toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); + action = toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); + action->setCheckable(true); + + + // ------------------------------------------------------------- HELP -------------------------------------------------------------------------------------------------- + menuBar()->addMenu( helpMenu() ); } @@ -405,31 +402,29 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { -// setUnifiedTitleAndToolBarOnMac(true); -// -// m_navigationBar = addToolBar(i18n("Navigation")); +// m_navigationBar = (KToolBar *) addToolBar(i18n("Navigation")); // connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); // -// m_historyBack->setIcon( KIcon("go-previous") ); -// m_historyBackMenu = new QMenu(this); +// m_historyBack->setIcon( (QIcon) KIcon("go-previous") ); +// m_historyBackMenu = new KMenu(this); // m_historyBack->setMenu(m_historyBackMenu); // connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); // connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); // m_navigationBar->addAction(m_historyBack); // -// m_historyForward->setIcon( KIcon("go-next") ); -// m_historyForwardMenu = new QMenu(this); +// m_historyForward->setIcon( (QIcon) KIcon("go-next") ); +// m_historyForwardMenu = new KMenu(this); // connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowForwardMenu())); // connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); // m_historyForward->setMenu(m_historyForwardMenu); // m_navigationBar->addAction(m_historyForward); // -// m_stopReload = new QAction(this); +// m_stopReload = new KAction(this); // m_reloadIcon = KIcon( "view-refresh" ); // m_stopReload->setIcon(m_reloadIcon); // m_navigationBar->addAction(m_stopReload); // -// m_goHome = new QAction(this); +// m_goHome = new KAction(this); // m_goHome->setIcon( KIcon( "go-home" ) ); // m_navigationBar->addAction(m_goHome); // connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); @@ -814,10 +809,10 @@ void BrowserMainWindow::slotViewPageSource() void BrowserMainWindow::slotHome() { - QSettings settings; +/* QSettings settings; settings.beginGroup(QLatin1String("MainWindow")); QString home = settings.value(QLatin1String("home"), QLatin1String("http://www.kde.org/")).toString(); - loadPage(home); + loadPage(home);*/ } diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 54c590e3..5570564f 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -114,6 +114,7 @@ private: void updateStatusbarActionText(bool visible); private: + KToolBar *m_navigationBar; ToolbarSearch *m_toolbarSearch; TabWidget *m_tabWidget; @@ -125,8 +126,8 @@ private: KMenu *m_historyForwardMenu; KMenu *m_windowMenu; - KAction *m_stop; - KAction *m_reload; + QAction *m_stop; + QAction *m_reload; KAction *m_stopReload; KAction *m_goHome; KAction *m_viewStatusbar; diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 6c340793..8808c926 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -385,7 +385,7 @@ QLineEdit *TabWidget::currentLineEdit() const WebView *TabWidget::currentWebView() const { - return webView(currentIndex()); +// return webView(currentIndex()); // FIXME } QLineEdit *TabWidget::lineEdit(int index) const @@ -406,7 +406,7 @@ WebView *TabWidget::webView(int index) const if (count() == 1) { TabWidget *that = const_cast(this); that->setUpdatesEnabled(false); - that->newTab(); +// that->newTab(); FIXME that->closeTab(0); that->setUpdatesEnabled(true); return currentWebView(); -- cgit v1.2.1 From 5a176b4641e10e25049a826025c4249fbcb07958 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 10 Nov 2008 11:53:23 +0100 Subject: 1st implementation of new find system --- src/CMakeLists.txt | 1 + src/browsermainwindow.cpp | 170 +++++++++++++++++++++------------------------- src/browsermainwindow.h | 11 ++- src/findwidget.cpp | 58 ++++++++++++++++ src/findwidget.h | 33 +++++++++ src/searchbar.h | 3 - src/tabwidget.cpp | 62 +++++++++-------- src/tabwidget.h | 19 ++++-- src/urllineedit.h | 7 +- 9 files changed, 230 insertions(+), 134 deletions(-) create mode 100644 src/findwidget.cpp create mode 100644 src/findwidget.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d10368f9..d4317b2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,7 @@ SET( rekonq_SRCS networkaccessmanager.cpp searchlineedit.cpp # searchbar.cpp + findwidget.cpp settings.cpp squeezelabel.cpp tabwidget.cpp diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 49b357c0..66679ad0 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -19,8 +19,8 @@  * ============================================================ */ +// Local Includes #include "browsermainwindow.h" - #include "autosaver.h" #include "bookmarks.h" #include "browserapplication.h" @@ -29,9 +29,12 @@ #include "settings.h" #include "tabwidget.h" #include "toolbarsearch.h" -#include "ui_passworddialog.h" #include "webview.h" +// UI Includes +#include "ui_passworddialog.h" + +// KDE Includes #include #include #include @@ -39,7 +42,7 @@ #include #include - +// Qt Includes #include #include #include @@ -50,10 +53,8 @@ #include #include #include - #include #include - #include @@ -78,6 +79,12 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) layout->setMargin(0); addToolBarBreak(); layout->addWidget(m_tabWidget); + + // Find Widget + m_findWidg = new FindWidget(centralWidget); + layout->addWidget(m_findWidg); +// m_findWidg->setVisible(false); + centralWidget->setLayout(layout); setCentralWidget(centralWidget); @@ -91,15 +98,12 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); -// connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), m_navigationBar, SLOT(setVisible(bool))); + connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), m_navigationBar, SLOT(setVisible(bool))); connect(m_tabWidget, SIGNAL(lastTabClosed()), m_tabWidget, SLOT(newTab())); slotUpdateWindowTitle(); loadDefaultState(); m_tabWidget->newTab(); - - int size = m_tabWidget->lineEditStack()->sizeHint().height(); -// m_navigationBar->setIconSize(QSize(size, size)); // FIXME re-enable me } @@ -114,11 +118,11 @@ BrowserMainWindow::~BrowserMainWindow() void BrowserMainWindow::loadDefaultState() { -// QSettings settings; -// settings.beginGroup(QLatin1String("BrowserMainWindow")); -// QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); -// // restoreState(data); // FIXME re-enable me! -// settings.endGroup(); + QSettings settings; + settings.beginGroup(QLatin1String("BrowserMainWindow")); + QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); +// restoreState(data); // FIXME re-enable me! + settings.endGroup(); } @@ -265,19 +269,9 @@ void BrowserMainWindow::setupMenu() editMenu->addSeparator(); - // FIXME port FIND system to KDE - QAction *m_find = editMenu->addAction(i18n("&Find")); - m_find->setShortcuts(QKeySequence::Find); - connect(m_find, SIGNAL(triggered()), this, SLOT(slotEditFind())); - new QShortcut(QKeySequence(Qt::Key_Slash), this, SLOT(slotEditFind())); - - QAction *m_findNext = editMenu->addAction( i18n("&Find Next")); - m_findNext->setShortcuts(QKeySequence::FindNext); - connect(m_findNext, SIGNAL(triggered()), this, SLOT(slotEditFindNext())); - - QAction *m_findPrevious = editMenu->addAction( i18n("&Find Previous")); - m_findPrevious->setShortcuts(QKeySequence::FindPrevious); - connect(m_findPrevious, SIGNAL(triggered()), this, SLOT(slotEditFindPrevious())); + editMenu->addAction( KStandardAction::find(this, SLOT( slotViewtFindWidget() ) , this ) ); + editMenu->addAction( KStandardAction::findNext(this, SLOT( slotEditFindNext() ) , this ) ); + editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotEditFindPrevious() ) , this ) ); editMenu->addSeparator(); @@ -295,14 +289,14 @@ void BrowserMainWindow::setupMenu() viewMenu->addSeparator(); - m_stop = viewMenu->addAction( i18n("&Stop") ); + m_stop = (KAction *) viewMenu->addAction( KIcon( "process-stop" ), i18n("&Stop") ); QList shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); shortcuts.append(Qt::Key_Escape); m_stop->setShortcuts(shortcuts); m_tabWidget->addWebAction(m_stop, QWebPage::Stop); - m_reload = viewMenu->addAction( i18n("Reload Page") ); + m_reload = (KAction *) viewMenu->addAction( KIcon("view-refresh"), i18n("Reload Page") ); m_reload->setShortcuts(QKeySequence::Refresh); m_tabWidget->addWebAction(m_reload, QWebPage::Reload); @@ -402,42 +396,36 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { -// m_navigationBar = (KToolBar *) addToolBar(i18n("Navigation")); -// connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); -// -// m_historyBack->setIcon( (QIcon) KIcon("go-previous") ); -// m_historyBackMenu = new KMenu(this); -// m_historyBack->setMenu(m_historyBackMenu); -// connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); -// connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); -// m_navigationBar->addAction(m_historyBack); -// -// m_historyForward->setIcon( (QIcon) KIcon("go-next") ); -// m_historyForwardMenu = new KMenu(this); -// connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowForwardMenu())); -// connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); -// m_historyForward->setMenu(m_historyForwardMenu); -// m_navigationBar->addAction(m_historyForward); -// -// m_stopReload = new KAction(this); -// m_reloadIcon = KIcon( "view-refresh" ); -// m_stopReload->setIcon(m_reloadIcon); -// m_navigationBar->addAction(m_stopReload); -// -// m_goHome = new KAction(this); -// m_goHome->setIcon( KIcon( "go-home" ) ); -// m_navigationBar->addAction(m_goHome); -// connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); -// -// m_navigationBar->addWidget(m_tabWidget->lineEditStack()); -// -// m_toolbarSearch = new ToolbarSearch(m_navigationBar); -// m_navigationBar->addWidget(m_toolbarSearch); -// -// // fixing toolbar movements -// m_navigationBar->setFloatable( false ); -// -// connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); + m_navigationBar = (KToolBar *) addToolBar(i18n("Navigation")); + connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); + + m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); + m_historyBackMenu = new KMenu(this); + m_historyBack->setMenu(m_historyBackMenu); + connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); + connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); + m_navigationBar->addAction(m_historyBack); + + m_historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); + m_historyForwardMenu = new KMenu(this); + connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowForwardMenu())); + connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); + m_historyForward->setMenu(m_historyForwardMenu); + m_navigationBar->addAction(m_historyForward); + + m_stopReload = new KAction( KIcon("view-refresh"), i18n("Reload"), this); + m_navigationBar->addAction(m_stopReload); + + m_goHome = new KAction( KIcon( "go-home" ), i18n("Home"),this); + m_navigationBar->addAction(m_goHome); + connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); + + m_navigationBar->addWidget(m_tabWidget->lineEditStack()); + + m_toolbarSearch = new ToolbarSearch(m_navigationBar); + m_navigationBar->addWidget(m_toolbarSearch); + + connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); } @@ -588,19 +576,6 @@ void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) - -void BrowserMainWindow::slotAboutApplication() -{ - QMessageBox::about(this, i18n("About"), - i18n( - "

reKonq is a simple KDE dedicated browser" - "

webkit and Qt Demo Browser based." // FIXME go new line.. - "

QtWebKit is based on the Open Source WebKit Project developed at http://webkit.org/." - )); -} - - - void BrowserMainWindow::slotFileNew() { BrowserApplication::instance()->newMainWindow(); @@ -711,21 +686,34 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event) } +void BrowserMainWindow::slotViewFindWidget() +{ + if ( m_findWidg->isVisible() ) + m_findWidg->setVisible( false ); + else + m_findWidg->setVisible( true ); +} +// FIXME: reimplement me A-LA KATE search bar void BrowserMainWindow::slotEditFind() { - if (!currentTab()) - return; - bool ok; - QString search = QInputDialog::getText(this, i18n("Find"), - i18n("Text:"), QLineEdit::Normal, - m_lastSearch, &ok); - if (ok && !search.isEmpty()) { - m_lastSearch = search; - if (!currentTab()->findText(m_lastSearch)) - slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); - } +// if (!currentTab()) +// return; +// bool ok; +// QString search = QInputDialog::getText(this, i18n("Find"), +// i18n("Text:"), QLineEdit::Normal, +// m_lastSearch, &ok); +// if (ok && !search.isEmpty()) { +// m_lastSearch = search; +// if (!currentTab()->findText(m_lastSearch)) +// slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); +// } +// m_findWidg->setVisible( true ); +/*if ( !currentTab() ) + return; +bool ok; +m_lastSearch = findWidg->*/ } @@ -809,10 +797,10 @@ void BrowserMainWindow::slotViewPageSource() void BrowserMainWindow::slotHome() { -/* QSettings settings; + QSettings settings; settings.beginGroup(QLatin1String("MainWindow")); QString home = settings.value(QLatin1String("home"), QLatin1String("http://www.kde.org/")).toString(); - loadPage(home);*/ + loadPage(home); } diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 5570564f..ee5e8989 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -22,14 +22,20 @@ #ifndef BROWSERMAINWINDOW_H #define BROWSERMAINWINDOW_H +// Local Includes +#include "findwidget.h" + +// KDE Includes #include #include #include #include #include +// Qt Includes #include + class AutoSaver; class QWebFrame; class TabWidget; @@ -93,7 +99,6 @@ private slots: void slotWebSearch(); void slotToggleInspector(bool enable); - void slotAboutApplication(); void slotDownloadManager(); void slotSelectLineEdit(); @@ -103,6 +108,7 @@ private slots: void slotOpenActionUrl(QAction *action); void slotShowWindow(); void slotSwapFocus(); + void slotViewFindWidget(); void printRequested(QWebFrame *frame); void geometryChangeRequested(const QRect &geometry); @@ -126,7 +132,7 @@ private: KMenu *m_historyForwardMenu; KMenu *m_windowMenu; - QAction *m_stop; + KAction *m_stop; QAction *m_reload; KAction *m_stopReload; KAction *m_goHome; @@ -137,6 +143,7 @@ private: KIcon m_reloadIcon; KIcon m_stopIcon; + FindWidget *m_findWidg; QString m_lastSearch; }; diff --git a/src/findwidget.cpp b/src/findwidget.cpp new file mode 100644 index 00000000..4eb10e6b --- /dev/null +++ b/src/findwidget.cpp @@ -0,0 +1,58 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#include "findwidget.h" + +#include +#include + +#include +#include +#include +#include + +FindWidget::FindWidget(QWidget * parent) : QWidget(parent) +{ + QHBoxLayout *layout = new QHBoxLayout(); + + KToolBar *bar1 = new KToolBar(this); + bar1->addAction( KStandardAction::close(this, SLOT( searchNow() ) , this ) ); + layout->addWidget( bar1 ); + + QLabel *label = new QLabel("Find: "); + layout->addWidget( label ); + + KLineEdit *findLineEdit = new KLineEdit(); + layout->addWidget( findLineEdit ); + + KToolBar *bar2 = new KToolBar(this); + bar2->addAction( KStandardAction::findNext(this, SLOT( searchNow() ) , this ) ); + bar2->addAction( KStandardAction::findPrev(this, SLOT( searchNow() ) , this ) ); + layout->addWidget( bar2 ); + + layout->addStretch(); + + setLayout(layout); +} + +QString FindWidget::searchNow() +{ + QString prova("adjam"); + return prova; +} diff --git a/src/findwidget.h b/src/findwidget.h new file mode 100644 index 00000000..5d8b7b28 --- /dev/null +++ b/src/findwidget.h @@ -0,0 +1,33 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef FINDWIDGET_H +#define FINDWIDGET_H + +#include + +class FindWidget : public QWidget +{ +public: + FindWidget(QWidget * parent = 0); + + QString searchNow(); +}; + +#endif diff --git a/src/searchbar.h b/src/searchbar.h index 222b97e4..e574508b 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -29,9 +29,6 @@ #include #include -class KHTMLPart; - - class SearchBarCombo : public KHistoryComboBox { Q_OBJECT diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 8808c926..892c4cc5 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -19,7 +19,7 @@  * ============================================================ */ - +// Local Includes #include "tabwidget.h" #include "browserapplication.h" @@ -28,6 +28,7 @@ #include "urllineedit.h" #include "webview.h" +// Qt Includes #include #include #include @@ -37,19 +38,19 @@ #include #include #include +#include -#include TabBar::TabBar(QWidget *parent) - : QTabBar(parent) + : KTabBar(parent) { setContextMenuPolicy(Qt::CustomContextMenu); setAcceptDrops(true); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(contextMenuRequested(const QPoint &))); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); QString alt = QLatin1String("Alt+%1"); - for (int i = 1; i <= 10; ++i) { + for (int i = 1; i <= 10; ++i) + { int key = i; if (key == 10) key = 0; @@ -61,7 +62,8 @@ TabBar::TabBar(QWidget *parent) void TabBar::selectTabAction() { - if (QShortcut *shortCut = qobject_cast(sender())) { + if (QShortcut *shortCut = qobject_cast(sender())) + { int index = m_tabShortcuts.indexOf(shortCut); if (index == 0) index = 10; @@ -74,27 +76,26 @@ void TabBar::contextMenuRequested(const QPoint &position) QMenu menu; menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); - if (-1 != index) { - QAction *action = menu.addAction(i18n("Clone Tab"), - this, SLOT(cloneTab())); + if (-1 != index) + { + QAction *action = menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); action->setData(index); menu.addSeparator(); - action = menu.addAction(i18n("&Close Tab"), - this, SLOT(closeTab()), QKeySequence::Close); + action = menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); action->setData(index); - action = menu.addAction(i18n("Close &Other Tabs"), - this, SLOT(closeOtherTabs())); + action = menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); action->setData(index); menu.addSeparator(); - action = menu.addAction(i18n("Reload Tab"), - this, SLOT(reloadTab()), QKeySequence::Refresh); + action = menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); - } else { + } + else + { menu.addSeparator(); } menu.addAction(i18n("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); @@ -111,7 +112,8 @@ void TabBar::cloneTab() void TabBar::closeTab() { - if (QAction *action = qobject_cast(sender())) { + if (QAction *action = qobject_cast(sender())) + { int index = action->data().toInt(); emit closeTab(index); } @@ -119,7 +121,8 @@ void TabBar::closeTab() void TabBar::closeOtherTabs() { - if (QAction *action = qobject_cast(sender())) { + if (QAction *action = qobject_cast(sender())) + { int index = action->data().toInt(); emit closeOtherTabs(index); } @@ -134,8 +137,8 @@ void TabBar::mousePressEvent(QMouseEvent *event) void TabBar::mouseMoveEvent(QMouseEvent *event) { - if (event->buttons() == Qt::LeftButton - && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) { + if (event->buttons() == Qt::LeftButton && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) + { QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; QList urls; @@ -155,8 +158,9 @@ void TabBar::dragEnterEvent(QDragEnterEvent *event) { const QMimeData *mimeData = event->mimeData(); QStringList formats = mimeData->formats(); - if (formats.contains(QLatin1String("action")) - && (mimeData->data(QLatin1String("action")) == "tab-reordering")) { + + if (formats.contains(QLatin1String("action")) && (mimeData->data(QLatin1String("action")) == "tab-reordering")) + { event->acceptProposedAction(); } QTabBar::dragEnterEvent(event); @@ -166,7 +170,8 @@ void TabBar::dropEvent(QDropEvent *event) { int fromIndex = tabAt(m_dragStartPos); int toIndex = tabAt(event->pos()); - if (fromIndex != toIndex) { + if (fromIndex != toIndex) + { emit tabMoveRequested(fromIndex, toIndex); event->acceptProposedAction(); } @@ -194,6 +199,8 @@ void TabBar::reloadTab() } } +// -------------------------------------------------------------------------------------------------------------------------------------------------------- + TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) @@ -268,8 +275,7 @@ TabWidget::TabWidget(QWidget *parent) closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); setCornerWidget(closeTabButton, Qt::TopRightCorner); - connect(this, SIGNAL(currentChanged(int)), - this, SLOT(currentChanged(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); } @@ -385,7 +391,7 @@ QLineEdit *TabWidget::currentLineEdit() const WebView *TabWidget::currentWebView() const { -// return webView(currentIndex()); // FIXME + return webView(currentIndex()); } QLineEdit *TabWidget::lineEdit(int index) const @@ -406,7 +412,7 @@ WebView *TabWidget::webView(int index) const if (count() == 1) { TabWidget *that = const_cast(this); that->setUpdatesEnabled(false); -// that->newTab(); FIXME + that->newTab(); that->closeTab(0); that->setUpdatesEnabled(true); return currentWebView(); diff --git a/src/tabwidget.h b/src/tabwidget.h index 15db1349..b3c31c0e 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -23,13 +23,12 @@ #ifndef TABWIDGET_H #define TABWIDGET_H -#include - -#include +#include +#include /* Tab bar with a few more features such as a context menu and shortcuts */ -class TabBar : public QTabBar +class TabBar : public KTabBar { Q_OBJECT @@ -67,7 +66,9 @@ private: int m_dragCurrentIndex; }; -#include + + +#include QT_BEGIN_NAMESPACE class QAction; @@ -102,8 +103,12 @@ private: QWebPage::WebAction m_webAction; }; -#include -#include + + + +#include +#include + QT_BEGIN_NAMESPACE class QCompleter; class QLineEdit; diff --git a/src/urllineedit.h b/src/urllineedit.h index 726a2b2b..eca0c1f5 100644 --- a/src/urllineedit.h +++ b/src/urllineedit.h @@ -21,9 +21,10 @@ #ifndef URLLINEEDIT_H #define URLLINEEDIT_H -#include -#include -#include +// Qt Includes +#include +#include +#include QT_BEGIN_NAMESPACE class QLineEdit; -- cgit v1.2.1 From 9fed2c5a1086dacb27659771c15cc34eb607a520 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 10 Nov 2008 15:36:59 +0100 Subject: Add COPYING file and updated FEATURES file. --- COPYING | 674 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FEATURES | 32 +++ 2 files changed, 706 insertions(+) create mode 100644 COPYING create mode 100644 FEATURES diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..94a9ed02 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/FEATURES b/FEATURES new file mode 100644 index 00000000..671155e6 --- /dev/null +++ b/FEATURES @@ -0,0 +1,32 @@ +TODO = - +DONE = + + +- fully ported to KDE4 +- Kconfig support (obviously..) +- threadweaver support +- kwallet support +- dbus support + +- kget support +- simple download support + +- share konqueror's bookmarks (akonadi) +- kio_bookmarks support +- NO bookmark manager (doing it with kio_bookmarks) + +- rewamp history +- new kio_history implementation + +- find text bar (a-la kate) + +- cookies +- webkit's inspector + +- Crash recovery handler + +- search bar (like konq-plugin, but "always" plugged in!!) +- Web Shortcuts (i.e. 'gg:reKonq' to search google for reKonq) + +- Adblock support + +--- 0.1 release --- -- cgit v1.2.1 From 92fc9f7f13542779f4bfea439a79a216af0d37e0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 13 Nov 2008 01:52:55 +0100 Subject: Re-enabled history! --- src/browsermainwindow.cpp | 70 ++++++++++++++++++++++------------------------- src/browsermainwindow.h | 6 ++-- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 66679ad0..c3f82354 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -310,38 +310,34 @@ void BrowserMainWindow::setupMenu() action->setCheckable(true); // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- -// HistoryMenu *historyMenu = new HistoryMenu(this); -// connect(historyMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); -// connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); -// historyMenu->setTitle( i18n("Hi&story") ); -// menuBar()->addMenu(historyMenu); -// QList historyActions; -// -// m_historyBack = new QAction( i18n("Back"), this); -// m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); -// m_historyBack->setShortcuts(QKeySequence::Back); -// m_historyBack->setIconVisibleInMenu(false); -// -// m_historyForward = new QAction( i18n("Forward"), this); -// m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); -// m_historyForward->setShortcuts(QKeySequence::Forward); -// m_historyForward->setIconVisibleInMenu(false); -// -// QAction *m_historyHome = new QAction( i18n("Home"), this); -// connect(m_historyHome, SIGNAL(triggered()), this, SLOT(slotHome())); -// m_historyHome->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_H)); -// -// m_restoreLastSession = new QAction( i18n("Restore Last Session"), this); -// connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); -// m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); -// -// historyActions.append(m_historyBack); -// historyActions.append(m_historyForward); -// historyActions.append(m_historyHome); -// historyActions.append(m_tabWidget->recentlyClosedTabsAction()); -// historyActions.append(m_restoreLastSession); -// historyMenu->setInitialActions(historyActions); -// + HistoryMenu *historyMenu = new HistoryMenu(this); + connect(historyMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); + historyMenu->setTitle( i18n("Hi&story") ); + menuBar()->addMenu(historyMenu); + QList historyActions; + + m_historyBack = new QAction( i18n("Back"), this); + m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); + m_historyBack->setShortcuts(QKeySequence::Back); + m_historyBack->setIconVisibleInMenu(false); + + m_historyForward = new QAction( i18n("Forward"), this); + m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); + m_historyForward->setShortcuts(QKeySequence::Forward); + m_historyForward->setIconVisibleInMenu(false); + + m_restoreLastSession = new QAction( i18n("Restore Last Session"), this); + connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); + m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); + + historyActions.append(m_historyBack); + historyActions.append(m_historyForward); + historyActions.append( KStandardAction::home(this, SLOT( slotHome() ) , this ) ); + historyActions.append(m_tabWidget->recentlyClosedTabsAction()); + historyActions.append(m_restoreLastSession); + historyMenu->setInitialActions(historyActions); + // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- @@ -352,10 +348,10 @@ void BrowserMainWindow::setupMenu() // menuBar()->addMenu(bookmarksMenu); // // // FIXME -// // BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); -// // bookmarksMenu->addAction(i18n("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); -// // bookmarksMenu->addAction(i18n("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); -// // bookmarksMenu->addSeparator(); +// BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); +// bookmarksMenu->addAction(i18n("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); +// bookmarksMenu->addAction(i18n("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); +// bookmarksMenu->addSeparator(); // // QList bookmarksActions; // @@ -370,7 +366,7 @@ void BrowserMainWindow::setupMenu() // bookmarksActions.append(showAllBookmarksAction); // bookmarksActions.append(m_addBookmark); // bookmarksMenu->setInitialActions(bookmarksActions); -// + // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- m_windowMenu = (KMenu *) menuBar()->addMenu( i18n("&Window") ); diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index ee5e8989..17aa1479 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -126,9 +126,9 @@ private: TabWidget *m_tabWidget; AutoSaver *m_autoSaver; - KAction *m_historyBack; + QAction *m_historyBack; KMenu *m_historyBackMenu; - KAction *m_historyForward; + QAction *m_historyForward; KMenu *m_historyForwardMenu; KMenu *m_windowMenu; @@ -137,7 +137,7 @@ private: KAction *m_stopReload; KAction *m_goHome; KAction *m_viewStatusbar; - KAction *m_restoreLastSession; + QAction *m_restoreLastSession; KAction *m_addBookmark; KIcon m_reloadIcon; -- cgit v1.2.1 From 76319190fa422c0a12417410ad12241172bf3c0a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 13 Nov 2008 03:13:34 +0100 Subject: 1st new implementation of KDE bookmarks system. The idea is to share konqueror bookmarks until we don't have an akonadi storage of them.. --- src/CMakeLists.txt | 5 +- src/addbookmarkdialog.ui | 98 ----- src/bookmarks.cpp | 968 --------------------------------------------- src/bookmarks.h | 289 -------------- src/bookmarks.ui | 106 ----- src/browserapplication.cpp | 13 - src/browserapplication.h | 3 - src/browsermainwindow.cpp | 68 ++-- src/browsermainwindow.h | 7 +- src/xbel.cpp | 304 -------------- src/xbel.h | 92 ----- 11 files changed, 31 insertions(+), 1922 deletions(-) delete mode 100644 src/addbookmarkdialog.ui delete mode 100644 src/bookmarks.cpp delete mode 100644 src/bookmarks.h delete mode 100644 src/bookmarks.ui delete mode 100644 src/xbel.cpp delete mode 100644 src/xbel.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d4317b2d..50b13782 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,5 @@ SET( rekonq_SRCS autosaver.cpp - bookmarks.cpp browserapplication.cpp browsermainwindow.cpp cookiejar.cpp @@ -19,13 +18,10 @@ SET( rekonq_SRCS toolbarsearch.cpp urllineedit.cpp webview.cpp - xbel.cpp main.cpp ) KDE4_ADD_UI_FILES( rekonq_SRCS - addbookmarkdialog.ui - bookmarks.ui cookies.ui cookiesexceptions.ui downloaditem.ui @@ -47,6 +43,7 @@ TARGET_LINK_LIBRARIES( rekonq ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} ${KDE4_KDEUI_LIBS} + ${KDE4_KIO_LIBS} ${QT_QTUITOOLS_LIBRARY} ) diff --git a/src/addbookmarkdialog.ui b/src/addbookmarkdialog.ui deleted file mode 100644 index 3460d7bb..00000000 --- a/src/addbookmarkdialog.ui +++ /dev/null @@ -1,98 +0,0 @@ - - AddBookmarkDialog - - - - 0 - 0 - 240 - 168 - - - - Add Bookmark - - - - - - Type a name for the bookmark, and choose where to keep it. - - - Qt::PlainText - - - true - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 2 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - false - - - - - - - - - buttonBox - accepted() - AddBookmarkDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - AddBookmarkDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp deleted file mode 100644 index 6f87d3a4..00000000 --- a/src/bookmarks.cpp +++ /dev/null @@ -1,968 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -// Local Includes -#include "bookmarks.h" -#include "autosaver.h" -#include "browserapplication.h" -#include "history.h" -#include "xbel.h" - -// Qt Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#define BOOKMARKBAR "Bookmarks Bar" -#define BOOKMARKMENU "Bookmarks Menu" - -BookmarksManager::BookmarksManager(QObject *parent) - : QObject(parent) - , m_loaded(false) - , m_saveTimer(new AutoSaver(this)) - , m_bookmarkRootNode(0) - , m_bookmarkModel(0) -{ - connect(this, SIGNAL(entryAdded(BookmarkNode *)), - m_saveTimer, SLOT(changeOccurred())); - connect(this, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), - m_saveTimer, SLOT(changeOccurred())); - connect(this, SIGNAL(entryChanged(BookmarkNode *)), - m_saveTimer, SLOT(changeOccurred())); -} - -BookmarksManager::~BookmarksManager() -{ - m_saveTimer->saveIfNeccessary(); -} - -void BookmarksManager::changeExpanded() -{ - m_saveTimer->changeOccurred(); -} - -void BookmarksManager::load() -{ - if (m_loaded) - return; - m_loaded = true; - - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); - if (!QFile::exists(bookmarkFile)) - bookmarkFile = QLatin1String(":defaultbookmarks.xbel"); - - XbelReader reader; - m_bookmarkRootNode = reader.read(bookmarkFile); - if (reader.error() != QXmlStreamReader::NoError) { - QMessageBox::warning(0, QLatin1String("Loading Bookmark"), - i18n("Error when loading bookmarks on line ") + - QString( (int) reader.lineNumber() ) + - i18n(", column ") + - QString( (int) reader.columnNumber() ) + - ":\n" + - reader.errorString() - ) ; - } - - BookmarkNode *toolbar = 0; - BookmarkNode *menu = 0; - QList others; - for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { - BookmarkNode *node = m_bookmarkRootNode->children().at(i); - if (node->type() == BookmarkNode::Folder) { - // Automatically convert - if (node->title == i18n("Toolbar Bookmarks") && !toolbar) { - node->title = i18n(BOOKMARKBAR); - } - if (node->title == i18n(BOOKMARKBAR) && !toolbar) { - toolbar = node; - } - - // Automatically convert - if (node->title == i18n("Menu") && !menu) { - node->title = i18n(BOOKMARKMENU); - } - if (node->title == i18n(BOOKMARKMENU) && !menu) { - menu = node; - } - } else { - others.append(node); - } - m_bookmarkRootNode->remove(node); - } - Q_ASSERT(m_bookmarkRootNode->children().count() == 0); - if (!toolbar) { - toolbar = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); - toolbar->title = i18n(BOOKMARKBAR); - } else { - m_bookmarkRootNode->add(toolbar); - } - - if (!menu) { - menu = new BookmarkNode(BookmarkNode::Folder, m_bookmarkRootNode); - menu->title = i18n(BOOKMARKMENU); - } else { - m_bookmarkRootNode->add(menu); - } - - for (int i = 0; i < others.count(); ++i) - menu->add(others.at(i)); -} - -void BookmarksManager::save() const -{ - if (!m_loaded) - return; - - XbelWriter writer; - QString dir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - QString bookmarkFile = dir + QLatin1String("/bookmarks.xbel"); - if (!writer.write(bookmarkFile, m_bookmarkRootNode)) - qWarning() << "BookmarkManager: error saving to" << bookmarkFile; -} - -void BookmarksManager::addBookmark(BookmarkNode *parent, BookmarkNode *node, int row) -{ - if (!m_loaded) - return; - Q_ASSERT(parent); - InsertBookmarksCommand *command = new InsertBookmarksCommand(this, parent, node, row); - m_commands.push(command); -} - -void BookmarksManager::removeBookmark(BookmarkNode *node) -{ - if (!m_loaded) - return; - - Q_ASSERT(node); - BookmarkNode *parent = node->parent(); - int row = parent->children().indexOf(node); - RemoveBookmarksCommand *command = new RemoveBookmarksCommand(this, parent, row); - m_commands.push(command); -} - -void BookmarksManager::setTitle(BookmarkNode *node, const QString &newTitle) -{ - if (!m_loaded) - return; - - Q_ASSERT(node); - ChangeBookmarkCommand *command = new ChangeBookmarkCommand(this, node, newTitle, true); - m_commands.push(command); -} - -void BookmarksManager::setUrl(BookmarkNode *node, const QString &newUrl) -{ - if (!m_loaded) - return; - - Q_ASSERT(node); - ChangeBookmarkCommand *command = new ChangeBookmarkCommand(this, node, newUrl, false); - m_commands.push(command); -} - -BookmarkNode *BookmarksManager::bookmarks() -{ - if (!m_loaded) - load(); - return m_bookmarkRootNode; -} - -BookmarkNode *BookmarksManager::menu() -{ - if (!m_loaded) - load(); - - for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { - BookmarkNode *node = m_bookmarkRootNode->children().at(i); - if (node->title == i18n(BOOKMARKMENU)) - return node; - } - Q_ASSERT(false); - return 0; -} - -BookmarkNode *BookmarksManager::toolbar() -{ - if (!m_loaded) - load(); - - for (int i = m_bookmarkRootNode->children().count() - 1; i >= 0; --i) { - BookmarkNode *node = m_bookmarkRootNode->children().at(i); - if (node->title == i18n(BOOKMARKBAR)) - return node; - } - Q_ASSERT(false); - return 0; -} - -BookmarksModel *BookmarksManager::bookmarksModel() -{ - if (!m_bookmarkModel) - m_bookmarkModel = new BookmarksModel(this, this); - return m_bookmarkModel; -} - -void BookmarksManager::importBookmarks() -{ - QString fileName = QFileDialog::getOpenFileName(0, i18n("Open File"), - QString(), - i18n("XBEL (*.xbel *.xml)")); - if (fileName.isEmpty()) - return; - - XbelReader reader; - BookmarkNode *importRootNode = reader.read(fileName); - if (reader.error() != QXmlStreamReader::NoError) { - QMessageBox::warning(0, QLatin1String("Loading Bookmark"), - i18n("Error when loading bookmarks on line %1, column %2:\n %3", reader.lineNumber(), reader.columnNumber(), reader.errorString() ) - ); - } - - importRootNode->setType(BookmarkNode::Folder); - importRootNode->title = ( i18n("Imported ") + QDate::currentDate().toString(Qt::SystemLocaleShortDate) ); - addBookmark(menu(), importRootNode); -} - -void BookmarksManager::exportBookmarks() -{ - QString fileName = QFileDialog::getSaveFileName(0, i18n("Save File"), - QCoreApplication::applicationName() + i18n(" Bookmarks.xbel"), - i18n("XBEL (*.xbel *.xml)")); - if (fileName.isEmpty()) - return; - - XbelWriter writer; - if (!writer.write(fileName, m_bookmarkRootNode)) - QMessageBox::critical(0, i18n("Export error"), i18n("error saving bookmarks")); -} - -RemoveBookmarksCommand::RemoveBookmarksCommand(BookmarksManager *m_bookmarkManagaer, BookmarkNode *parent, int row) - : QUndoCommand( i18n("Remove Bookmark") ) - , m_row(row) - , m_bookmarkManagaer(m_bookmarkManagaer) - , m_node(parent->children().value(row)) - , m_parent(parent) - , m_done(false) -{ -} - -RemoveBookmarksCommand::~RemoveBookmarksCommand() -{ - if (m_done && !m_node->parent()) { - delete m_node; - } -} - -void RemoveBookmarksCommand::undo() -{ - m_parent->add(m_node, m_row); - emit m_bookmarkManagaer->entryAdded(m_node); - m_done = false; -} - -void RemoveBookmarksCommand::redo() -{ - m_parent->remove(m_node); - emit m_bookmarkManagaer->entryRemoved(m_parent, m_row, m_node); - m_done = true; -} - -InsertBookmarksCommand::InsertBookmarksCommand(BookmarksManager *m_bookmarkManagaer, - BookmarkNode *parent, BookmarkNode *node, int row) - : RemoveBookmarksCommand(m_bookmarkManagaer, parent, row) -{ - setText( i18n("Insert Bookmark") ); - m_node = node; -} - -ChangeBookmarkCommand::ChangeBookmarkCommand(BookmarksManager *m_bookmarkManagaer, BookmarkNode *node, - const QString &newValue, bool title) - : QUndoCommand() - , m_bookmarkManagaer(m_bookmarkManagaer) - , m_title(title) - , m_newValue(newValue) - , m_node(node) -{ - if (m_title) { - m_oldValue = m_node->title; - setText( i18n("Name Change") ); - } else { - m_oldValue = m_node->url; - setText( i18n("Address Change") ); - } -} - -void ChangeBookmarkCommand::undo() -{ - if (m_title) - m_node->title = m_oldValue; - else - m_node->url = m_oldValue; - emit m_bookmarkManagaer->entryChanged(m_node); -} - -void ChangeBookmarkCommand::redo() -{ - if (m_title) - m_node->title = m_newValue; - else - m_node->url = m_newValue; - emit m_bookmarkManagaer->entryChanged(m_node); -} - -BookmarksModel::BookmarksModel(BookmarksManager *bookmarkManager, QObject *parent) - : QAbstractItemModel(parent) - , m_endMacro(false) - , m_bookmarksManager(bookmarkManager) -{ - connect(bookmarkManager, SIGNAL(entryAdded(BookmarkNode *)), this, SLOT(entryAdded(BookmarkNode *))); - connect(bookmarkManager, SIGNAL(entryRemoved(BookmarkNode *, int, BookmarkNode *)), this, SLOT(entryRemoved(BookmarkNode *, int, BookmarkNode *))); - connect(bookmarkManager, SIGNAL(entryChanged(BookmarkNode *)), this, SLOT(entryChanged(BookmarkNode *))); -} - -QModelIndex BookmarksModel::index(BookmarkNode *node) const -{ - BookmarkNode *parent = node->parent(); - if (!parent) - return QModelIndex(); - return createIndex(parent->children().indexOf(node), 0, node); -} - -void BookmarksModel::entryAdded(BookmarkNode *item) -{ - Q_ASSERT(item && item->parent()); - int row = item->parent()->children().indexOf(item); - BookmarkNode *parent = item->parent(); - // item was already added so remove beore beginInsertRows is called - parent->remove(item); - beginInsertRows(index(parent), row, row); - parent->add(item, row); - endInsertRows(); -} - -void BookmarksModel::entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item) -{ - // item was already removed, re-add so beginRemoveRows works - parent->add(item, row); - beginRemoveRows(index(parent), row, row); - parent->remove(item); - endRemoveRows(); -} - -void BookmarksModel::entryChanged(BookmarkNode *item) -{ - QModelIndex idx = index(item); - emit dataChanged(idx, idx); -} - -bool BookmarksModel::removeRows(int row, int count, const QModelIndex &parent) -{ - if (row < 0 || count <= 0 || row + count > rowCount(parent)) - return false; - - BookmarkNode *bookmarkNode = node(parent); - for (int i = row + count - 1; i >= row; --i) { - BookmarkNode *node = bookmarkNode->children().at(i); - if (node == m_bookmarksManager->menu() - || node == m_bookmarksManager->toolbar()) - continue; - - m_bookmarksManager->removeBookmark(node); - } - if (m_endMacro) { - m_bookmarksManager->undoRedoStack()->endMacro(); - m_endMacro = false; - } - return true; -} - -QVariant BookmarksModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch (section) { - case 0: return i18n("Title"); - case 1: return i18n("Address"); - } - } - return QAbstractItemModel::headerData(section, orientation, role); -} - -QVariant BookmarksModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.model() != this) - return QVariant(); - - const BookmarkNode *bookmarkNode = node(index); - switch (role) { - case Qt::EditRole: - case Qt::DisplayRole: - if (bookmarkNode->type() == BookmarkNode::Separator) { - switch (index.column()) { - case 0: return QString(50, 0xB7); - case 1: return QString(); - } - } - - switch (index.column()) { - case 0: return bookmarkNode->title; - case 1: return bookmarkNode->url; - } - break; - case BookmarksModel::UrlRole: - return QUrl(bookmarkNode->url); - break; - case BookmarksModel::UrlStringRole: - return bookmarkNode->url; - break; - case BookmarksModel::TypeRole: - return bookmarkNode->type(); - break; - case BookmarksModel::SeparatorRole: - return (bookmarkNode->type() == BookmarkNode::Separator); - break; - case Qt::DecorationRole: - if (index.column() == 0) { - if (bookmarkNode->type() == BookmarkNode::Folder) - return QApplication::style()->standardIcon(QStyle::SP_DirIcon); - return BrowserApplication::instance()->icon(bookmarkNode->url); - } - } - - return QVariant(); -} - -int BookmarksModel::columnCount(const QModelIndex &parent) const -{ - return (parent.column() > 0) ? 0 : 2; -} - -int BookmarksModel::rowCount(const QModelIndex &parent) const -{ - if (parent.column() > 0) - return 0; - - if (!parent.isValid()) - return m_bookmarksManager->bookmarks()->children().count(); - - const BookmarkNode *item = static_cast(parent.internalPointer()); - return item->children().count(); -} - -QModelIndex BookmarksModel::index(int row, int column, const QModelIndex &parent) const -{ - if (row < 0 || column < 0 || row >= rowCount(parent) || column >= columnCount(parent)) - return QModelIndex(); - - // get the parent node - BookmarkNode *parentNode = node(parent); - return createIndex(row, column, parentNode->children().at(row)); -} - -QModelIndex BookmarksModel::parent(const QModelIndex &index) const -{ - if (!index.isValid()) - return QModelIndex(); - - BookmarkNode *itemNode = node(index); - BookmarkNode *parentNode = (itemNode ? itemNode->parent() : 0); - if (!parentNode || parentNode == m_bookmarksManager->bookmarks()) - return QModelIndex(); - - // get the parent's row - BookmarkNode *grandParentNode = parentNode->parent(); - int parentRow = grandParentNode->children().indexOf(parentNode); - Q_ASSERT(parentRow >= 0); - return createIndex(parentRow, 0, parentNode); -} - -bool BookmarksModel::hasChildren(const QModelIndex &parent) const -{ - if (!parent.isValid()) - return true; - const BookmarkNode *parentNode = node(parent); - return (parentNode->type() == BookmarkNode::Folder); -} - -Qt::ItemFlags BookmarksModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return Qt::NoItemFlags; - - Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled; - - BookmarkNode *bookmarkNode = node(index); - - if (bookmarkNode != m_bookmarksManager->menu() - && bookmarkNode != m_bookmarksManager->toolbar()) { - flags |= Qt::ItemIsDragEnabled; - if (bookmarkNode->type() != BookmarkNode::Separator) - flags |= Qt::ItemIsEditable; - } - if (hasChildren(index)) - flags |= Qt::ItemIsDropEnabled; - return flags; -} - -Qt::DropActions BookmarksModel::supportedDropActions () const -{ - return Qt::CopyAction | Qt::MoveAction; -} - -#define MIMETYPE QLatin1String("application/bookmarks.xbel") - -QStringList BookmarksModel::mimeTypes() const -{ - QStringList types; - types << MIMETYPE; - return types; -} - -QMimeData *BookmarksModel::mimeData(const QModelIndexList &indexes) const -{ - QMimeData *mimeData = new QMimeData(); - QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); - foreach (QModelIndex index, indexes) { - if (index.column() != 0 || !index.isValid()) - continue; - QByteArray encodedData; - QBuffer buffer(&encodedData); - buffer.open(QBuffer::ReadWrite); - XbelWriter writer; - const BookmarkNode *parentNode = node(index); - writer.write(&buffer, parentNode); - stream << encodedData; - } - mimeData->setData(MIMETYPE, data); - return mimeData; -} - -bool BookmarksModel::dropMimeData(const QMimeData *data, - Qt::DropAction action, int row, int column, const QModelIndex &parent) -{ - if (action == Qt::IgnoreAction) - return true; - - if (!data->hasFormat(MIMETYPE) - || column > 0) - return false; - - QByteArray ba = data->data(MIMETYPE); - QDataStream stream(&ba, QIODevice::ReadOnly); - if (stream.atEnd()) - return false; - - QUndoStack *undoStack = m_bookmarksManager->undoRedoStack(); - undoStack->beginMacro(QLatin1String("Move Bookmarks")); - - while (!stream.atEnd()) { - QByteArray encodedData; - stream >> encodedData; - QBuffer buffer(&encodedData); - buffer.open(QBuffer::ReadOnly); - - XbelReader reader; - BookmarkNode *rootNode = reader.read(&buffer); - QList children = rootNode->children(); - for (int i = 0; i < children.count(); ++i) { - BookmarkNode *bookmarkNode = children.at(i); - rootNode->remove(bookmarkNode); - row = qMax(0, row); - BookmarkNode *parentNode = node(parent); - m_bookmarksManager->addBookmark(parentNode, bookmarkNode, row); - m_endMacro = true; - } - delete rootNode; - } - return true; -} - -bool BookmarksModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (!index.isValid() || (flags(index) & Qt::ItemIsEditable) == 0) - return false; - - BookmarkNode *item = node(index); - - switch (role) { - case Qt::EditRole: - case Qt::DisplayRole: - if (index.column() == 0) { - m_bookmarksManager->setTitle(item, value.toString()); - break; - } - if (index.column() == 1) { - m_bookmarksManager->setUrl(item, value.toString()); - break; - } - return false; - case BookmarksModel::UrlRole: - m_bookmarksManager->setUrl(item, value.toUrl().toString()); - break; - case BookmarksModel::UrlStringRole: - m_bookmarksManager->setUrl(item, value.toString()); - break; - default: - break; - return false; - } - - return true; -} - -BookmarkNode *BookmarksModel::node(const QModelIndex &index) const -{ - BookmarkNode *itemNode = static_cast(index.internalPointer()); - if (!itemNode) - return m_bookmarksManager->bookmarks(); - return itemNode; -} - - -AddBookmarkProxyModel::AddBookmarkProxyModel(QObject *parent) - : QSortFilterProxyModel(parent) -{ -} - -int AddBookmarkProxyModel::columnCount(const QModelIndex &parent) const -{ - return qMin(1, QSortFilterProxyModel::columnCount(parent)); -} - -bool AddBookmarkProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const -{ - QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); - return sourceModel()->hasChildren(idx); -} - -AddBookmarkDialog::AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent, BookmarksManager *bookmarkManager) - : QDialog(parent) - , m_url(url) - , m_bookmarksManager(bookmarkManager) -{ - setWindowFlags(Qt::Sheet); - if (!m_bookmarksManager) - m_bookmarksManager = BrowserApplication::bookmarksManager(); - setupUi(this); - QTreeView *view = new QTreeView(this); - m_proxyModel = new AddBookmarkProxyModel(this); - BookmarksModel *model = m_bookmarksManager->bookmarksModel(); - m_proxyModel->setSourceModel(model); - view->setModel(m_proxyModel); - view->expandAll(); - view->header()->setStretchLastSection(true); - view->header()->hide(); - view->setItemsExpandable(false); - view->setRootIsDecorated(false); - view->setIndentation(10); - location->setModel(m_proxyModel); - view->show(); - location->setView(view); - BookmarkNode *menu = m_bookmarksManager->menu(); - QModelIndex idx = m_proxyModel->mapFromSource(model->index(menu)); - view->setCurrentIndex(idx); - location->setCurrentIndex(idx.row()); - name->setText(title); -} - -void AddBookmarkDialog::accept() -{ - QModelIndex index = location->view()->currentIndex(); - index = m_proxyModel->mapToSource(index); - if (!index.isValid()) - index = m_bookmarksManager->bookmarksModel()->index(0, 0); - BookmarkNode *parent = m_bookmarksManager->bookmarksModel()->node(index); - BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark); - bookmark->url = m_url; - bookmark->title = name->text(); - m_bookmarksManager->addBookmark(parent, bookmark); - QDialog::accept(); -} - -BookmarksMenu::BookmarksMenu(QWidget *parent) - : ModelMenu(parent) - , m_bookmarksManager(0) -{ - connect(this, SIGNAL(activated(const QModelIndex &)), - this, SLOT(activated(const QModelIndex &))); - setMaxRows(-1); - setHoverRole(BookmarksModel::UrlStringRole); - setSeparatorRole(BookmarksModel::SeparatorRole); -} - -void BookmarksMenu::activated(const QModelIndex &index) -{ - emit openUrl(index.data(BookmarksModel::UrlRole).toUrl()); -} - -bool BookmarksMenu::prePopulated() -{ - m_bookmarksManager = BrowserApplication::bookmarksManager(); - setModel(m_bookmarksManager->bookmarksModel()); - setRootIndex(m_bookmarksManager->bookmarksModel()->index(1, 0)); - // initial actions - for (int i = 0; i < m_initialActions.count(); ++i) - addAction(m_initialActions.at(i)); - if (!m_initialActions.isEmpty()) - addSeparator(); - createMenu(model()->index(0, 0), 1, this); - return true; -} - -void BookmarksMenu::setInitialActions(QList actions) -{ - m_initialActions = actions; - for (int i = 0; i < m_initialActions.count(); ++i) - addAction(m_initialActions.at(i)); -} - -BookmarksDialog::BookmarksDialog(QWidget *parent, BookmarksManager *manager) - : QDialog(parent) -{ - m_bookmarksManager = manager; - if (!m_bookmarksManager) - m_bookmarksManager = BrowserApplication::bookmarksManager(); - setupUi(this); - - tree->setUniformRowHeights(true); - tree->setSelectionBehavior(QAbstractItemView::SelectRows); - tree->setSelectionMode(QAbstractItemView::ContiguousSelection); - tree->setTextElideMode(Qt::ElideMiddle); - m_bookmarksModel = m_bookmarksManager->bookmarksModel(); - m_proxyModel = new TreeProxyModel(this); - connect(search, SIGNAL(textChanged(QString)), - m_proxyModel, SLOT(setFilterFixedString(QString))); - connect(removeButton, SIGNAL(clicked()), tree, SLOT(removeOne())); - m_proxyModel->setSourceModel(m_bookmarksModel); - tree->setModel(m_proxyModel); - tree->setDragDropMode(QAbstractItemView::InternalMove); - tree->setExpanded(m_proxyModel->index(0, 0), true); - tree->setAlternatingRowColors(true); - QFontMetrics fm(font()); - int header = fm.width(QLatin1Char('m')) * 40; - tree->header()->resizeSection(0, header); - tree->header()->setStretchLastSection(true); - connect(tree, SIGNAL(activated(const QModelIndex&)), - this, SLOT(open())); - tree->setContextMenuPolicy(Qt::CustomContextMenu); - connect(tree, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(customContextMenuRequested(const QPoint &))); - connect(addFolderButton, SIGNAL(clicked()), - this, SLOT(newFolder())); - expandNodes(m_bookmarksManager->bookmarks()); - setAttribute(Qt::WA_DeleteOnClose); -} - -BookmarksDialog::~BookmarksDialog() -{ - if (saveExpandedNodes(tree->rootIndex())) - m_bookmarksManager->changeExpanded(); -} - -bool BookmarksDialog::saveExpandedNodes(const QModelIndex &parent) -{ - bool changed = false; - for (int i = 0; i < m_proxyModel->rowCount(parent); ++i) { - QModelIndex child = m_proxyModel->index(i, 0, parent); - QModelIndex sourceIndex = m_proxyModel->mapToSource(child); - BookmarkNode *childNode = m_bookmarksModel->node(sourceIndex); - bool wasExpanded = childNode->expanded; - if (tree->isExpanded(child)) { - childNode->expanded = true; - changed |= saveExpandedNodes(child); - } else { - childNode->expanded = false; - } - changed |= (wasExpanded != childNode->expanded); - } - return changed; -} - -void BookmarksDialog::expandNodes(BookmarkNode *node) -{ - for (int i = 0; i < node->children().count(); ++i) { - BookmarkNode *childNode = node->children()[i]; - if (childNode->expanded) { - QModelIndex idx = m_bookmarksModel->index(childNode); - idx = m_proxyModel->mapFromSource(idx); - tree->setExpanded(idx, true); - expandNodes(childNode); - } - } -} - -void BookmarksDialog::customContextMenuRequested(const QPoint &pos) -{ - QMenu menu; - QModelIndex index = tree->indexAt(pos); - index = index.sibling(index.row(), 0); - if (index.isValid() && !tree->model()->hasChildren(index)) { - menu.addAction( i18n("Open"), this, SLOT(open())); - menu.addSeparator(); - } - menu.addAction( i18n("Delete"), tree, SLOT(removeOne())); - menu.exec(QCursor::pos()); -} - -void BookmarksDialog::open() -{ - QModelIndex index = tree->currentIndex(); - if (!index.parent().isValid()) - return; - emit openUrl(index.sibling(index.row(), 1).data(BookmarksModel::UrlRole).toUrl()); -} - -void BookmarksDialog::newFolder() -{ - QModelIndex currentIndex = tree->currentIndex(); - QModelIndex idx = currentIndex; - if (idx.isValid() && !idx.model()->hasChildren(idx)) - idx = idx.parent(); - if (!idx.isValid()) - idx = tree->rootIndex(); - idx = m_proxyModel->mapToSource(idx); - BookmarkNode *parent = m_bookmarksManager->bookmarksModel()->node(idx); - BookmarkNode *node = new BookmarkNode(BookmarkNode::Folder); - node->title = i18n("New Folder"); - m_bookmarksManager->addBookmark(parent, node, currentIndex.row() + 1); -} - -BookmarksToolBar::BookmarksToolBar(BookmarksModel *model, QWidget *parent) - : QToolBar( i18n("Bookmark"), parent) - , m_bookmarksModel(model) -{ - connect(this, SIGNAL(actionTriggered(QAction*)), this, SLOT(triggered(QAction*))); - setRootIndex(model->index(0, 0)); - connect(m_bookmarksModel, SIGNAL(modelReset()), this, SLOT(build())); - connect(m_bookmarksModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(build())); - connect(m_bookmarksModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(build())); - connect(m_bookmarksModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(build())); - setAcceptDrops(true); -} - -void BookmarksToolBar::dragEnterEvent(QDragEnterEvent *event) -{ - const QMimeData *mimeData = event->mimeData(); - if (mimeData->hasUrls()) - event->acceptProposedAction(); - QToolBar::dragEnterEvent(event); -} - -void BookmarksToolBar::dropEvent(QDropEvent *event) -{ - const QMimeData *mimeData = event->mimeData(); - if (mimeData->hasUrls() && mimeData->hasText()) { - QList urls = mimeData->urls(); - QAction *action = actionAt(event->pos()); - QString dropText; - if (action) - dropText = action->text(); - int row = -1; - QModelIndex parentIndex = m_root; - for (int i = 0; i < m_bookmarksModel->rowCount(m_root); ++i) { - QModelIndex idx = m_bookmarksModel->index(i, 0, m_root); - QString title = idx.data().toString(); - if (title == dropText) { - row = i; - if (m_bookmarksModel->hasChildren(idx)) { - parentIndex = idx; - row = -1; - } - break; - } - } - BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark); - bookmark->url = urls.at(0).toString(); - bookmark->title = mimeData->text(); - - BookmarkNode *parent = m_bookmarksModel->node(parentIndex); - BookmarksManager *bookmarksManager = m_bookmarksModel->bookmarksManager(); - bookmarksManager->addBookmark(parent, bookmark, row); - event->acceptProposedAction(); - } - QToolBar::dropEvent(event); -} - - -void BookmarksToolBar::setRootIndex(const QModelIndex &index) -{ - m_root = index; - build(); -} - -QModelIndex BookmarksToolBar::rootIndex() const -{ - return m_root; -} - -void BookmarksToolBar::build() -{ - clear(); - for (int i = 0; i < m_bookmarksModel->rowCount(m_root); ++i) { - QModelIndex idx = m_bookmarksModel->index(i, 0, m_root); - if (m_bookmarksModel->hasChildren(idx)) { - QToolButton *button = new QToolButton(this); - button->setPopupMode(QToolButton::InstantPopup); - button->setArrowType(Qt::DownArrow); - button->setText(idx.data().toString()); - ModelMenu *menu = new ModelMenu(this); - connect(menu, SIGNAL(activated(const QModelIndex &)), - this, SLOT(activated(const QModelIndex &))); - menu->setModel(m_bookmarksModel); - menu->setRootIndex(idx); - menu->addAction(new QAction(menu)); - button->setMenu(menu); - button->setToolButtonStyle(Qt::ToolButtonTextOnly); - QAction *a = addWidget(button); - a->setText(idx.data().toString()); - } else { - QAction *action = addAction(idx.data().toString()); - action->setData(idx.data(BookmarksModel::UrlRole)); - } - } -} - -void BookmarksToolBar::triggered(QAction *action) -{ - QVariant v = action->data(); - if (v.canConvert()) { - emit openUrl(v.toUrl()); - } -} - -void BookmarksToolBar::activated(const QModelIndex &index) -{ - emit openUrl(index.data(BookmarksModel::UrlRole).toUrl()); -} - diff --git a/src/bookmarks.h b/src/bookmarks.h deleted file mode 100644 index 4ce3e49f..00000000 --- a/src/bookmarks.h +++ /dev/null @@ -1,289 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef BOOKMARKS_H -#define BOOKMARKS_H - -#include -#include - -#include - -/*! - Bookmark manager, owner of the bookmarks, loads, saves and basic tasks - */ -class AutoSaver; -class BookmarkNode; -class BookmarksModel; -class BookmarksManager : public QObject -{ - Q_OBJECT - -signals: - void entryAdded(BookmarkNode *item); - void entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item); - void entryChanged(BookmarkNode *item); - -public: - BookmarksManager(QObject *parent = 0); - ~BookmarksManager(); - - void addBookmark(BookmarkNode *parent, BookmarkNode *node, int row = -1); - void removeBookmark(BookmarkNode *node); - void setTitle(BookmarkNode *node, const QString &newTitle); - void setUrl(BookmarkNode *node, const QString &newUrl); - void changeExpanded(); - - BookmarkNode *bookmarks(); - BookmarkNode *menu(); - BookmarkNode *toolbar(); - - BookmarksModel *bookmarksModel(); - QUndoStack *undoRedoStack() { return &m_commands; }; - -public slots: - void importBookmarks(); - void exportBookmarks(); - -private slots: - void save() const; - -private: - void load(); - - bool m_loaded; - AutoSaver *m_saveTimer; - BookmarkNode *m_bookmarkRootNode; - BookmarksModel *m_bookmarkModel; - QUndoStack m_commands; - - friend class RemoveBookmarksCommand; - friend class ChangeBookmarkCommand; -}; - -class RemoveBookmarksCommand : public QUndoCommand -{ - -public: - RemoveBookmarksCommand(BookmarksManager *m_bookmarkManagaer, BookmarkNode *parent, int row); - ~RemoveBookmarksCommand(); - void undo(); - void redo(); - -protected: - int m_row; - BookmarksManager *m_bookmarkManagaer; - BookmarkNode *m_node; - BookmarkNode *m_parent; - bool m_done; -}; - -class InsertBookmarksCommand : public RemoveBookmarksCommand -{ - -public: - InsertBookmarksCommand(BookmarksManager *m_bookmarkManagaer, - BookmarkNode *parent, BookmarkNode *node, int row); - void undo() { RemoveBookmarksCommand::redo(); } - void redo() { RemoveBookmarksCommand::undo(); } - -}; - -class ChangeBookmarkCommand : public QUndoCommand -{ - -public: - ChangeBookmarkCommand(BookmarksManager *m_bookmarkManagaer, - BookmarkNode *node, const QString &newValue, bool title); - void undo(); - void redo(); - -private: - BookmarksManager *m_bookmarkManagaer; - bool m_title; - QString m_oldValue; - QString m_newValue; - BookmarkNode *m_node; -}; - -/*! - BookmarksModel is a QAbstractItemModel wrapper around the BookmarkManager - */ -#include -class BookmarksModel : public QAbstractItemModel -{ - Q_OBJECT - -public slots: - void entryAdded(BookmarkNode *item); - void entryRemoved(BookmarkNode *parent, int row, BookmarkNode *item); - void entryChanged(BookmarkNode *item); - -public: - enum Roles { - TypeRole = Qt::UserRole + 1, - UrlRole = Qt::UserRole + 2, - UrlStringRole = Qt::UserRole + 3, - SeparatorRole = Qt::UserRole + 4 - }; - - BookmarksModel(BookmarksManager *bookmarkManager, QObject *parent = 0); - inline BookmarksManager *bookmarksManager() const { return m_bookmarksManager; } - - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; - QModelIndex parent(const QModelIndex& index= QModelIndex()) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - Qt::DropActions supportedDropActions () const; - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - QMimeData *mimeData(const QModelIndexList &indexes) const; - QStringList mimeTypes() const; - bool dropMimeData(const QMimeData *data, - Qt::DropAction action, int row, int column, const QModelIndex &parent); - bool hasChildren(const QModelIndex &parent = QModelIndex()) const; - - BookmarkNode *node(const QModelIndex &index) const; - QModelIndex index(BookmarkNode *node) const; - -private: - - bool m_endMacro; - BookmarksManager *m_bookmarksManager; -}; - -// Menu that is dynamically populated from the bookmarks -#include "modelmenu.h" -class BookmarksMenu : public ModelMenu -{ - Q_OBJECT - -signals: - void openUrl(const QUrl &url); - -public: - BookmarksMenu(QWidget *parent = 0); - void setInitialActions(QList actions); - -protected: - bool prePopulated(); - -private slots: - void activated(const QModelIndex &index); - -private: - BookmarksManager *m_bookmarksManager; - QList m_initialActions; -}; - -/* - Proxy model that filters out the bookmarks so only the folders - are left behind. Used in the add bookmark dialog combobox. - */ -#include -class AddBookmarkProxyModel : public QSortFilterProxyModel -{ - Q_OBJECT -public: - AddBookmarkProxyModel(QObject * parent = 0); - int columnCount(const QModelIndex & parent = QModelIndex()) const; - -protected: - bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; -}; - -/*! - Add bookmark dialog - */ -#include "ui_addbookmarkdialog.h" -class AddBookmarkDialog : public QDialog, public Ui_AddBookmarkDialog -{ - Q_OBJECT - -public: - AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent = 0, BookmarksManager *bookmarkManager = 0); - -private slots: - void accept(); - -private: - QString m_url; - BookmarksManager *m_bookmarksManager; - AddBookmarkProxyModel *m_proxyModel; -}; - -#include "ui_bookmarks.h" -class TreeProxyModel; -class BookmarksDialog : public QDialog, public Ui_BookmarksDialog -{ - Q_OBJECT - -signals: - void openUrl(const QUrl &url); - -public: - BookmarksDialog(QWidget *parent = 0, BookmarksManager *manager = 0); - ~BookmarksDialog(); - -private slots: - void customContextMenuRequested(const QPoint &pos); - void open(); - void newFolder(); - -private: - void expandNodes(BookmarkNode *node); - bool saveExpandedNodes(const QModelIndex &parent); - - BookmarksManager *m_bookmarksManager; - BookmarksModel *m_bookmarksModel; - TreeProxyModel *m_proxyModel; -}; - -#include -class BookmarksToolBar : public QToolBar -{ - Q_OBJECT - -signals: - void openUrl(const QUrl &url); - -public: - BookmarksToolBar(BookmarksModel *model, QWidget *parent = 0); - void setRootIndex(const QModelIndex &index); - QModelIndex rootIndex() const; - -protected: - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); - -private slots: - void triggered(QAction *action); - void activated(const QModelIndex &index); - void build(); - -private: - BookmarksModel *m_bookmarksModel; - QPersistentModelIndex m_root; -}; - -#endif // BOOKMARKS_H diff --git a/src/bookmarks.ui b/src/bookmarks.ui deleted file mode 100644 index c893e941..00000000 --- a/src/bookmarks.ui +++ /dev/null @@ -1,106 +0,0 @@ - - BookmarksDialog - - - - 0 - 0 - 758 - 450 - - - - Bookmarks - - - - - - Qt::Horizontal - - - - 252 - 20 - - - - - - - - - - - - - - - - &Remove - - - - - - - Add Folder - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QDialogButtonBox::Ok - - - - - - - - - - SearchLineEdit - QLineEdit -

searchlineedit.h
- - - EditTreeView - QTreeView -
edittreeview.h
-
- - - - - buttonBox - accepted() - BookmarksDialog - accept() - - - 472 - 329 - - - 461 - 356 - - - - - diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 2a487143..7a125bdc 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -21,7 +21,6 @@ #include "browserapplication.h" -#include "bookmarks.h" #include "browsermainwindow.h" #include "cookiejar.h" #include "downloadmanager.h" @@ -52,7 +51,6 @@ DownloadManager *BrowserApplication::s_downloadManager = 0; HistoryManager *BrowserApplication::s_historyManager = 0; NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0; -BookmarksManager *BrowserApplication::s_bookmarksManager = 0; @@ -109,7 +107,6 @@ BrowserApplication::~BrowserApplication() delete s_downloadManager; qDeleteAll(m_mainWindows); delete s_networkAccessManager; - delete s_bookmarksManager; } @@ -392,16 +389,6 @@ HistoryManager *BrowserApplication::historyManager() -BookmarksManager *BrowserApplication::bookmarksManager() -{ - if (!s_bookmarksManager) { - s_bookmarksManager = new BookmarksManager; - } - return s_bookmarksManager; -} - - - KIcon BrowserApplication::icon(const QUrl &url) const { KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); diff --git a/src/browserapplication.h b/src/browserapplication.h index 95b93218..43d374d3 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -33,7 +33,6 @@ QT_BEGIN_NAMESPACE class QLocalServer; QT_END_NAMESPACE -class BookmarksManager; class BrowserMainWindow; class CookieJar; class DownloadManager; @@ -62,7 +61,6 @@ public: static CookieJar *cookieJar(); static DownloadManager *downloadManager(); static NetworkAccessManager *networkAccessManager(); - static BookmarksManager *bookmarksManager(); public slots: BrowserMainWindow *newMainWindow(); @@ -80,7 +78,6 @@ private: static HistoryManager *s_historyManager; static DownloadManager *s_downloadManager; static NetworkAccessManager *s_networkAccessManager; - static BookmarksManager *s_bookmarksManager; QList > m_mainWindows; QLocalServer *m_localServer; diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index c3f82354..7aa4a899 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -22,7 +22,6 @@ // Local Includes #include "browsermainwindow.h" #include "autosaver.h" -#include "bookmarks.h" #include "browserapplication.h" #include "downloadmanager.h" #include "history.h" @@ -41,6 +40,8 @@ #include #include #include +#include +#include // Qt Includes #include @@ -66,6 +67,7 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) , m_historyForward(0) , m_stop(0) , m_reload(0) + , m_bookmarkMenu(0) { setAttribute(Qt::WA_DeleteOnClose, true); statusBar()->setSizeGripEnabled(true); @@ -191,13 +193,11 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) QSize size; bool showToolbar; - bool showBookmarksBar; bool showStatusbar; QByteArray tabState; stream >> size; stream >> showToolbar; - stream >> showBookmarksBar; stream >> showStatusbar; stream >> tabState; @@ -341,32 +341,14 @@ void BrowserMainWindow::setupMenu() // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- -// BookmarksMenu *bookmarksMenu = new BookmarksMenu(this); -// connect(bookmarksMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); -// connect(bookmarksMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); -// bookmarksMenu->setTitle(i18n("&Bookmarks")); -// menuBar()->addMenu(bookmarksMenu); -// -// // FIXME -// BookmarksManager *bookmarksManager = BrowserApplication::bookmarksManager(); -// bookmarksMenu->addAction(i18n("&Import Bookmarks..."), bookmarksManager, SLOT(importBookmarks())); -// bookmarksMenu->addAction(i18n("&Export Bookmarks..."), bookmarksManager, SLOT(exportBookmarks())); -// bookmarksMenu->addSeparator(); -// -// QList bookmarksActions; -// -// QAction *showAllBookmarksAction = new QAction(i18n("Show All Bookmarks"), this); -// connect(showAllBookmarksAction, SIGNAL(triggered()), this, SLOT(slotShowBookmarksDialog())); -// m_addBookmark = new QAction( KIcon("bookmark-new"), i18n("Add Bookmark..."), this); -// m_addBookmark->setIconVisibleInMenu(false); -// -// connect(m_addBookmark, SIGNAL(triggered()), this, SLOT(slotAddBookmark())); -// m_addBookmark->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D)); -// -// bookmarksActions.append(showAllBookmarksAction); -// bookmarksActions.append(m_addBookmark); -// bookmarksMenu->setInitialActions(bookmarksActions); + KMenu* bookmarksMenu = new KMenu( i18n("&Bookmarks"), this ); + + menuBar()->addMenu( bookmarksMenu ); + + KBookmarkManager *mgr = KBookmarkManager::managerForFile( "~/.kde/share/apps/konqueror/bookmarks.xml" , "konqueror" ); + KActionCollection * ac = new KActionCollection( this ); + m_bookmarkMenu = new KBookmarkMenu( mgr , 0 , bookmarksMenu , ac ); // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- m_windowMenu = (KMenu *) menuBar()->addMenu( i18n("&Window") ); @@ -393,7 +375,7 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { m_navigationBar = (KToolBar *) addToolBar(i18n("Navigation")); - connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); +// connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); @@ -427,24 +409,24 @@ void BrowserMainWindow::setupToolBar() -void BrowserMainWindow::slotShowBookmarksDialog() -{ - BookmarksDialog *dialog = new BookmarksDialog(this); - connect(dialog, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); - dialog->show(); -} +// void BrowserMainWindow::slotShowBookmarksDialog() +// { +// BookmarksDialog *dialog = new BookmarksDialog(this); +// connect(dialog, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); +// dialog->show(); +// } -void BrowserMainWindow::slotAddBookmark() -{ - WebView *webView = currentTab(); - QString url = webView->url().toString(); - QString title = webView->title(); - AddBookmarkDialog dialog(url, title); - dialog.exec(); -} +// void BrowserMainWindow::slotAddBookmark() +// { +// WebView *webView = currentTab(); +// QString url = webView->url().toString(); +// QString title = webView->title(); +// AddBookmarkDialog dialog(url, title); +// dialog.exec(); +// } void BrowserMainWindow::updateStatusbarActionText(bool visible) diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 17aa1479..8f4a30f9 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -31,6 +31,7 @@ #include #include #include +#include // Qt Includes #include @@ -88,8 +89,8 @@ private slots: void slotEditFind(); void slotEditFindNext(); void slotEditFindPrevious(); - void slotShowBookmarksDialog(); - void slotAddBookmark(); +/* void slotShowBookmarksDialog(); + void slotAddBookmark();*/ void slotViewTextBigger(); void slotViewTextNormal(); void slotViewTextSmaller(); @@ -145,6 +146,8 @@ private: FindWidget *m_findWidg; QString m_lastSearch; + + KBookmarkMenu* m_bookmarkMenu; }; #endif // BROWSERMAINWINDOW_H diff --git a/src/xbel.cpp b/src/xbel.cpp deleted file mode 100644 index 13a91ccb..00000000 --- a/src/xbel.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -// Local Includes -#include "xbel.h" - -// KDE Includes -#include - -// Qt Includes -#include - - -BookmarkNode::BookmarkNode(BookmarkNode::Type type, BookmarkNode *parent) : - expanded(false) - , m_parent(parent) - , m_type(type) -{ - if (parent) - parent->add(this); -} - -BookmarkNode::~BookmarkNode() -{ - if (m_parent) - m_parent->remove(this); - qDeleteAll(m_children); - m_parent = 0; - m_type = BookmarkNode::Root; -} - -bool BookmarkNode::operator==(const BookmarkNode &other) -{ - if (url != other.url - || title != other.title - || desc != other.desc - || expanded != other.expanded - || m_type != other.m_type - || m_children.count() != other.m_children.count()) - return false; - - for (int i = 0; i < m_children.count(); ++i) - if (!((*(m_children[i])) == (*(other.m_children[i])))) - return false; - return true; -} - -BookmarkNode::Type BookmarkNode::type() const -{ - return m_type; -} - -void BookmarkNode::setType(Type type) -{ - m_type = type; -} - -QList BookmarkNode::children() const -{ - return m_children; -} - -BookmarkNode *BookmarkNode::parent() const -{ - return m_parent; -} - -void BookmarkNode::add(BookmarkNode *child, int offset) -{ - Q_ASSERT(child->m_type != Root); - if (child->m_parent) - child->m_parent->remove(child); - child->m_parent = this; - if (-1 == offset) - offset = m_children.size(); - m_children.insert(offset, child); -} - -void BookmarkNode::remove(BookmarkNode *child) -{ - child->m_parent = 0; - m_children.removeAll(child); -} - - -XbelReader::XbelReader() -{ -} - -BookmarkNode *XbelReader::read(const QString &fileName) -{ - QFile file(fileName); - if (!file.exists()) { - return new BookmarkNode(BookmarkNode::Root); - } - file.open(QFile::ReadOnly); - return read(&file); -} - -BookmarkNode *XbelReader::read(QIODevice *device) -{ - BookmarkNode *root = new BookmarkNode(BookmarkNode::Root); - setDevice(device); - while (!atEnd()) { - readNext(); - if (isStartElement()) { - QString version = attributes().value(QLatin1String("version")).toString(); - if (name() == QLatin1String("xbel") - && (version.isEmpty() || version == QLatin1String("1.0"))) { - readXBEL(root); - } else { - raiseError( i18n("The file is not an XBEL version 1.0 file.") ); - } - } - } - return root; -} - -void XbelReader::readXBEL(BookmarkNode *parent) -{ - Q_ASSERT(isStartElement() && name() == QLatin1String("xbel")); - - while (!atEnd()) { - readNext(); - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("folder")) - readFolder(parent); - else if (name() == QLatin1String("bookmark")) - readBookmarkNode(parent); - else if (name() == QLatin1String("separator")) - readSeparator(parent); - else - skipUnknownElement(); - } - } -} - -void XbelReader::readFolder(BookmarkNode *parent) -{ - Q_ASSERT(isStartElement() && name() == QLatin1String("folder")); - - BookmarkNode *folder = new BookmarkNode(BookmarkNode::Folder, parent); - folder->expanded = (attributes().value(QLatin1String("folded")) == QLatin1String("no")); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("title")) - readTitle(folder); - else if (name() == QLatin1String("desc")) - readDescription(folder); - else if (name() == QLatin1String("folder")) - readFolder(folder); - else if (name() == QLatin1String("bookmark")) - readBookmarkNode(folder); - else if (name() == QLatin1String("separator")) - readSeparator(folder); - else - skipUnknownElement(); - } - } -} - -void XbelReader::readTitle(BookmarkNode *parent) -{ - Q_ASSERT(isStartElement() && name() == QLatin1String("title")); - parent->title = readElementText(); -} - -void XbelReader::readDescription(BookmarkNode *parent) -{ - Q_ASSERT(isStartElement() && name() == QLatin1String("desc")); - parent->desc = readElementText(); -} - -void XbelReader::readSeparator(BookmarkNode *parent) -{ - new BookmarkNode(BookmarkNode::Separator, parent); - // empty elements have a start and end element - readNext(); -} - -void XbelReader::readBookmarkNode(BookmarkNode *parent) -{ - Q_ASSERT(isStartElement() && name() == QLatin1String("bookmark")); - BookmarkNode *bookmark = new BookmarkNode(BookmarkNode::Bookmark, parent); - bookmark->url = attributes().value(QLatin1String("href")).toString(); - while (!atEnd()) { - readNext(); - if (isEndElement()) - break; - - if (isStartElement()) { - if (name() == QLatin1String("title")) - readTitle(bookmark); - else if (name() == QLatin1String("desc")) - readDescription(bookmark); - else - skipUnknownElement(); - } - } - if (bookmark->title.isEmpty()) - bookmark->title = i18n("Unknown title"); -} - -void XbelReader::skipUnknownElement() -{ - Q_ASSERT(isStartElement()); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) - skipUnknownElement(); - } -} - - -XbelWriter::XbelWriter() -{ - setAutoFormatting(true); -} - -bool XbelWriter::write(const QString &fileName, const BookmarkNode *root) -{ - QFile file(fileName); - if (!root || !file.open(QFile::WriteOnly)) - return false; - return write(&file, root); -} - -bool XbelWriter::write(QIODevice *device, const BookmarkNode *root) -{ - setDevice(device); - - writeStartDocument(); - writeDTD(QLatin1String("")); - writeStartElement(QLatin1String("xbel")); - writeAttribute(QLatin1String("version"), QLatin1String("1.0")); - if (root->type() == BookmarkNode::Root) { - for (int i = 0; i < root->children().count(); ++i) - writeItem(root->children().at(i)); - } else { - writeItem(root); - } - - writeEndDocument(); - return true; -} - -void XbelWriter::writeItem(const BookmarkNode *parent) -{ - switch (parent->type()) { - case BookmarkNode::Folder: - writeStartElement(QLatin1String("folder")); - writeAttribute(QLatin1String("folded"), parent->expanded ? QLatin1String("no") : QLatin1String("yes")); - writeTextElement(QLatin1String("title"), parent->title); - for (int i = 0; i < parent->children().count(); ++i) - writeItem(parent->children().at(i)); - writeEndElement(); - break; - case BookmarkNode::Bookmark: - writeStartElement(QLatin1String("bookmark")); - if (!parent->url.isEmpty()) - writeAttribute(QLatin1String("href"), parent->url); - writeTextElement(QLatin1String("title"), parent->title); - if (!parent->desc.isEmpty()) - writeAttribute(QLatin1String("desc"), parent->desc); - writeEndElement(); - break; - case BookmarkNode::Separator: - writeEmptyElement(QLatin1String("separator")); - break; - default: - break; - } -} diff --git a/src/xbel.h b/src/xbel.h deleted file mode 100644 index b636a437..00000000 --- a/src/xbel.h +++ /dev/null @@ -1,92 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef XBEL_H -#define XBEL_H - -#include -#include - -class BookmarkNode -{ -public: - enum Type { - Root, - Folder, - Bookmark, - Separator - }; - - BookmarkNode(Type type = Root, BookmarkNode *parent = 0); - ~BookmarkNode(); - bool operator==(const BookmarkNode &other); - - Type type() const; - void setType(Type type); - QList children() const; - BookmarkNode *parent() const; - - void add(BookmarkNode *child, int offset = -1); - void remove(BookmarkNode *child); - - QString url; - QString title; - QString desc; - bool expanded; - -private: - BookmarkNode *m_parent; - Type m_type; - QList m_children; - -}; - -class XbelReader : public QXmlStreamReader -{ -public: - XbelReader(); - BookmarkNode *read(const QString &fileName); - BookmarkNode *read(QIODevice *device); - -private: - void skipUnknownElement(); - void readXBEL(BookmarkNode *parent); - void readTitle(BookmarkNode *parent); - void readDescription(BookmarkNode *parent); - void readSeparator(BookmarkNode *parent); - void readFolder(BookmarkNode *parent); - void readBookmarkNode(BookmarkNode *parent); -}; - -#include - -class XbelWriter : public QXmlStreamWriter -{ -public: - XbelWriter(); - bool write(const QString &fileName, const BookmarkNode *root); - bool write(QIODevice *device, const BookmarkNode *root); - -private: - void writeItem(const BookmarkNode *parent); -}; - -#endif // XBEL_H - -- cgit v1.2.1 From e601b33c753e5812e6cff04b07ca190285bcbf05 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 13 Nov 2008 10:53:14 +0100 Subject: Some porting, lots of QAction converted, history and bookmarks re-enabled, search bar temporarly removed --- src/browsermainwindow.cpp | 80 ++++++++++++++--------------------------------- src/browsermainwindow.h | 8 ++--- 2 files changed, 27 insertions(+), 61 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 7aa4a899..ef796ff7 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -83,8 +83,8 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) layout->addWidget(m_tabWidget); // Find Widget - m_findWidg = new FindWidget(centralWidget); - layout->addWidget(m_findWidg); +/* m_findWidg = new FindWidget(centralWidget); + layout->addWidget(m_findWidg);*/ // m_findWidg->setVisible(false); centralWidget->setLayout(layout); @@ -245,26 +245,26 @@ void BrowserMainWindow::setupMenu() // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- KMenu *editMenu = (KMenu *) menuBar()->addMenu( i18n("&Edit") ); - QAction *m_undo = editMenu->addAction(i18n("&Undo")); - m_undo->setShortcuts(QKeySequence::Undo); + KAction *m_undo = KStandardAction::undo( this , 0 , this ); + editMenu->addAction( m_undo ); m_tabWidget->addWebAction(m_undo, QWebPage::Undo); - QAction *m_redo = editMenu->addAction(i18n("&Redo")); - m_redo->setShortcuts(QKeySequence::Redo); + KAction *m_redo = KStandardAction::redo( this , 0 , this ); + editMenu->addAction( m_redo ); m_tabWidget->addWebAction(m_redo, QWebPage::Redo); editMenu->addSeparator(); - QAction *m_cut = editMenu->addAction(i18n("Cu&t")); - m_cut->setShortcuts(QKeySequence::Cut); + KAction *m_cut = KStandardAction::cut( this , 0 , this ); + editMenu->addAction( m_cut ); m_tabWidget->addWebAction(m_cut, QWebPage::Cut); - QAction *m_copy = editMenu->addAction(i18n("&Copy")); - m_copy->setShortcuts(QKeySequence::Copy); + KAction *m_copy = KStandardAction::copy( this , 0 , this ); + editMenu->addAction( m_copy ); m_tabWidget->addWebAction(m_copy, QWebPage::Copy); - QAction *m_paste = editMenu->addAction(i18n("&Paste")); - m_paste->setShortcuts(QKeySequence::Paste); + KAction *m_paste = KStandardAction::paste( this , 0 , this ); + editMenu->addAction( m_paste ); m_tabWidget->addWebAction(m_paste, QWebPage::Paste); editMenu->addSeparator(); @@ -348,6 +348,7 @@ void BrowserMainWindow::setupMenu() KBookmarkManager *mgr = KBookmarkManager::managerForFile( "~/.kde/share/apps/konqueror/bookmarks.xml" , "konqueror" ); KActionCollection * ac = new KActionCollection( this ); + ac->addAction( "Add Bookmark" , KStandardAction::addBookmark( this, SLOT( slotAddBookmark() ) , this ) ); m_bookmarkMenu = new KBookmarkMenu( mgr , 0 , bookmarksMenu , ac ); // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- @@ -375,7 +376,6 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { m_navigationBar = (KToolBar *) addToolBar(i18n("Navigation")); -// connect(m_navigationBar->toggleViewAction(), SIGNAL(toggled(bool)), this, SLOT(updateToolbarActionText(bool))); m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); @@ -385,10 +385,6 @@ void BrowserMainWindow::setupToolBar() m_navigationBar->addAction(m_historyBack); m_historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); - m_historyForwardMenu = new KMenu(this); - connect(m_historyForwardMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowForwardMenu())); - connect(m_historyForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - m_historyForward->setMenu(m_historyForwardMenu); m_navigationBar->addAction(m_historyForward); m_stopReload = new KAction( KIcon("view-refresh"), i18n("Reload"), this); @@ -408,25 +404,14 @@ void BrowserMainWindow::setupToolBar() - -// void BrowserMainWindow::slotShowBookmarksDialog() -// { -// BookmarksDialog *dialog = new BookmarksDialog(this); -// connect(dialog, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); -// dialog->show(); -// } - - - - -// void BrowserMainWindow::slotAddBookmark() -// { +void BrowserMainWindow::slotAddBookmark() +{ // WebView *webView = currentTab(); // QString url = webView->url().toString(); // QString title = webView->title(); // AddBookmarkDialog dialog(url, title); // dialog.exec(); -// } +} void BrowserMainWindow::updateStatusbarActionText(bool visible) @@ -849,16 +834,19 @@ WebView *BrowserMainWindow::currentTab() const void BrowserMainWindow::slotLoadProgress(int progress) { - if (progress < 100 && progress > 0) { + if (progress < 100 && progress > 0) + { disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); if (m_stopIcon.isNull()) - m_stopIcon = KIcon( style()->standardIcon(QStyle::SP_BrowserStop) ); + m_stopIcon = KIcon( "process-stop" ); m_stopReload->setIcon(m_stopIcon); connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); m_stopReload->setToolTip( i18n("Stop loading the current page") ); - } else { + } + else + { disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); - m_stopReload->setIcon(m_reloadIcon); + m_stopReload->setIcon( KIcon("view-refresh") ); connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); m_stopReload->setToolTip( i18n("Reload the current page") ); } @@ -887,28 +875,6 @@ void BrowserMainWindow::slotAboutToShowBackMenu() - -void BrowserMainWindow::slotAboutToShowForwardMenu() -{ - m_historyForwardMenu->clear(); - if (!currentTab()) - return; - QWebHistory *history = currentTab()->history(); - int historyCount = history->count(); - for (int i = 0; i < history->forwardItems(history->count()).count(); ++i) { - QWebHistoryItem item = history->forwardItems(historyCount).at(i); - QAction *action = new QAction(this); - action->setData(historyCount-i); - QIcon icon = BrowserApplication::instance()->icon(item.url()); - action->setIcon(icon); - action->setText(item.title()); - m_historyForwardMenu->addAction(action); - } -} - - - - void BrowserMainWindow::slotAboutToShowWindowMenu() { m_windowMenu->clear(); diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 8f4a30f9..66d77043 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -89,8 +89,8 @@ private slots: void slotEditFind(); void slotEditFindNext(); void slotEditFindPrevious(); -/* void slotShowBookmarksDialog(); - void slotAddBookmark();*/ +// void slotShowBookmarksDialog(); + void slotAddBookmark(); void slotViewTextBigger(); void slotViewTextNormal(); void slotViewTextSmaller(); @@ -104,7 +104,7 @@ private slots: void slotSelectLineEdit(); void slotAboutToShowBackMenu(); - void slotAboutToShowForwardMenu(); +// void slotAboutToShowForwardMenu(); void slotAboutToShowWindowMenu(); void slotOpenActionUrl(QAction *action); void slotShowWindow(); @@ -130,7 +130,7 @@ private: QAction *m_historyBack; KMenu *m_historyBackMenu; QAction *m_historyForward; - KMenu *m_historyForwardMenu; +// KMenu *m_historyForwardMenu; KMenu *m_windowMenu; KAction *m_stop; -- cgit v1.2.1 From c6646ccdae1c9b25a44e93c0a31298ec89797934 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 13 Nov 2008 11:43:05 +0100 Subject: New 1st implementation of text search bar. It is currently not working. Anyway, good starting point.. --- src/CMakeLists.txt | 2 +- src/browsermainwindow.cpp | 23 +-- src/browsermainwindow.h | 8 +- src/searchbar.cpp | 474 +++++++--------------------------------------- src/searchbar.h | 79 ++------ 5 files changed, 99 insertions(+), 487 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50b13782..a30af320 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,7 @@ SET( rekonq_SRCS modelmenu.cpp networkaccessmanager.cpp searchlineedit.cpp -# searchbar.cpp + searchbar.cpp findwidget.cpp settings.cpp squeezelabel.cpp diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index ef796ff7..81784a62 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -82,10 +82,9 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) addToolBarBreak(); layout->addWidget(m_tabWidget); - // Find Widget -/* m_findWidg = new FindWidget(centralWidget); - layout->addWidget(m_findWidg);*/ -// m_findWidg->setVisible(false); + // Search Bar + m_searchBar = new SearchBar(centralWidget); + layout->addWidget(m_searchBar); centralWidget->setLayout(layout); setCentralWidget(centralWidget); @@ -269,7 +268,7 @@ void BrowserMainWindow::setupMenu() editMenu->addSeparator(); - editMenu->addAction( KStandardAction::find(this, SLOT( slotViewtFindWidget() ) , this ) ); + editMenu->addAction( KStandardAction::find(this, SLOT( slotViewSearchBar() ) , this ) ); editMenu->addAction( KStandardAction::findNext(this, SLOT( slotEditFindNext() ) , this ) ); editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotEditFindPrevious() ) , this ) ); @@ -649,15 +648,6 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event) } -void BrowserMainWindow::slotViewFindWidget() -{ - if ( m_findWidg->isVisible() ) - m_findWidg->setVisible( false ); - else - m_findWidg->setVisible( true ); -} - - // FIXME: reimplement me A-LA KATE search bar void BrowserMainWindow::slotEditFind() { @@ -679,7 +669,10 @@ bool ok; m_lastSearch = findWidg->*/ } - +void BrowserMainWindow::slotViewSearchBar() +{ + m_searchBar->show(); +} void BrowserMainWindow::slotEditFindNext() { diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 66d77043..faf98e93 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -23,7 +23,7 @@ #define BROWSERMAINWINDOW_H // Local Includes -#include "findwidget.h" +#include "searchbar.h" // KDE Includes #include @@ -89,7 +89,6 @@ private slots: void slotEditFind(); void slotEditFindNext(); void slotEditFindPrevious(); -// void slotShowBookmarksDialog(); void slotAddBookmark(); void slotViewTextBigger(); void slotViewTextNormal(); @@ -97,6 +96,7 @@ private slots: void slotViewStatusbar(); void slotViewPageSource(); void slotViewFullScreen(bool enable); + void slotViewSearchBar(); void slotWebSearch(); void slotToggleInspector(bool enable); @@ -104,12 +104,10 @@ private slots: void slotSelectLineEdit(); void slotAboutToShowBackMenu(); -// void slotAboutToShowForwardMenu(); void slotAboutToShowWindowMenu(); void slotOpenActionUrl(QAction *action); void slotShowWindow(); void slotSwapFocus(); - void slotViewFindWidget(); void printRequested(QWebFrame *frame); void geometryChangeRequested(const QRect &geometry); @@ -144,7 +142,7 @@ private: KIcon m_reloadIcon; KIcon m_stopIcon; - FindWidget *m_findWidg; + SearchBar *m_searchBar; QString m_lastSearch; KBookmarkMenu* m_bookmarkMenu; diff --git a/src/searchbar.cpp b/src/searchbar.cpp index f1f6ef80..b0e91fa9 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright 2008 Benjamin C. Meyer * Copyright (C) 2008 by Andrea Diamantini  * * @@ -18,460 +19,123 @@  * ============================================================ */ #include "searchbar.h" +#include "moc_searchbar.cpp" +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include +#include +#include +#include #include -#include - - +#include +#include - -SearchBar::SearchBar() : - m_searchCombo(0), - m_searchMode(UseSearchProvider), - m_urlEnterLock(false), - m_process(0) +SearchBar::SearchBar(QWidget *parent) + : QWidget(parent) + , m_object(0) + , m_widget(0) + , m_lineEdit(0) { - m_searchCombo = new SearchBarCombo(0); - m_searchCombo->lineEdit()->installEventFilter(this); - connect(m_searchCombo, SIGNAL(activated(const QString &)), SLOT(startSearch(const QString &))); - connect(m_searchCombo, SIGNAL(iconClicked()), SLOT(showSelectionMenu())); - m_searchCombo->setWhatsThis(i18n("Search Bar

" - "Enter a search term. Click on the icon to change search mode or provider.

")); - - m_popupMenu = 0; - - m_searchComboAction = actionCollection()->addAction("toolbar_search_bar"); - m_searchComboAction->setText(i18n("Search Bar")); - m_searchComboAction->setDefaultWidget(m_searchCombo); - m_searchComboAction->setShortcutConfigurable(false); + initializeSearchWidget(); + // we start off hidden + setMaximumHeight(0); +// m_widget->setGeometry(0, -1 * m_widget->height(), m_widget->width(), m_widget->height()); + hide(); - KAction *a = actionCollection()->addAction("focus_search_bar"); - a->setText(i18n("Focus Searchbar")); - a->setShortcut(Qt::CTRL+Qt::Key_S); - connect(a, SIGNAL(triggered()), this, SLOT(focusSearchbar())); - - configurationChanged(); - - // parent is the KonqMainWindow and we want to listen to PartActivateEvent events. - parent->installEventFilter(this); + new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(hide())); } - - SearchBar::~SearchBar() { - KConfigGroup config(KGlobal::config(), "SearchBar"); - config.writeEntry("Mode", (int) m_searchMode); - config.writeEntry("CurrentEngine", m_currentEngine); - - delete m_searchCombo; - m_searchCombo = 0L; - delete m_process; - m_process=0L; -} - -static QChar delimiter() -{ - static QChar s_delimiter = 0; - if (s_delimiter == 0) { - KConfig _config("kuriikwsfilterrc", KConfig::NoGlobals); - KConfigGroup config(&_config, "General"); - s_delimiter = config.readEntry("KeywordDelimiter", int(':')); - } - return s_delimiter; + delete m_object; + delete m_widget; + delete m_lineEdit; } - -void SearchBar::nextSearchEntry() +void SearchBar::initializeSearchWidget() { - if (m_searchMode == FindInThisPage) { - m_searchMode = UseSearchProvider; - if (!m_searchEngines.isEmpty()) { - m_currentEngine = m_searchEngines.first(); - } else { - m_currentEngine = "google"; - } - } else { - int index = m_searchEngines.indexOf(m_currentEngine); - ++index; - if (index >= m_searchEngines.count()) { - m_searchMode = FindInThisPage; - } else { - m_currentEngine = m_searchEngines.at(index); - } - } - setIcon(); -} + QHBoxLayout *layout = new QHBoxLayout(); -void SearchBar::previousSearchEntry() -{ - if (m_searchMode == FindInThisPage) { - m_searchMode = UseSearchProvider; - if (!m_searchEngines.isEmpty()) { - m_currentEngine = m_searchEngines.last(); - } else { - m_currentEngine = "google"; - } - } else { - int index = m_searchEngines.indexOf(m_currentEngine); - if (index == 0) { - m_searchMode = FindInThisPage; - } else { - --index; - m_currentEngine = m_searchEngines.at(index); - } - } - setIcon(); -} + KToolBar *bar1 = new KToolBar(this); + bar1->addAction( KStandardAction::close(this, SLOT( hide() ) , this ) ); + layout->addWidget( bar1 ); -void SearchBar::startSearch(const QString &search) -{ - if ( m_urlEnterLock || search.isEmpty() ) - return; - if (m_searchMode == UseSearchProvider) { - m_urlEnterLock = true; - KService::Ptr service; - KUriFilterData data; - QStringList list; - list << "kurisearchfilter" << "kuriikwsfilter"; + QLabel *label = new QLabel("Find: "); + layout->addWidget( label ); - service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine)); - if (service) { - const QString searchProviderPrefix = service->property("Keys").toStringList().first() + delimiter(); - data.setData(searchProviderPrefix + search); - } + m_lineEdit = new KLineEdit(); + connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); + connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); + layout->addWidget( m_lineEdit ); - if (!service || !KUriFilter::self()->filterUri(data, list)) { - data.setData(QLatin1String("google") + delimiter() + search); - KUriFilter::self()->filterUri(data, list); - } + KToolBar *bar2 = new KToolBar(this); + bar2->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); + bar2->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); + layout->addWidget( bar2 ); - if (QApplication::keyboardModifiers() & Qt::ControlModifier) { - KParts::OpenUrlArguments arguments; - KParts::BrowserArguments browserArguments; - browserArguments.setNewTab(true); - if (ext) - emit ext->createNewWindow(data.uri(), arguments, browserArguments); - } else { - if (ext) { - emit ext->openUrlRequest(data.uri()); - m_part->widget()->setFocus(); // #152923 - } - } - } + layout->addStretch(); - m_searchCombo->addToHistory(search); - m_searchCombo->setItemIcon(0, m_searchIcon); - - m_urlEnterLock = false; + setLayout(layout); } -void SearchBarPlugin::setIcon() -{ - if (m_searchMode == FindInThisPage) { - m_searchIcon = SmallIcon("edit-find"); - } else { - KService::Ptr service; - KUriFilterData data; - QStringList list; - list << "kurisearchfilter" << "kuriikwsfilter"; - - service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine)); - if (service) { - const QString searchProviderPrefix = service->property("Keys").toStringList().first() + delimiter(); - data.setData(searchProviderPrefix + "some keyword"); - } - - if (service && KUriFilter::self()->filterUri(data, list)) - { - QString iconPath = KStandardDirs::locate("cache", KMimeType::favIconForUrl(data.uri()) + ".png"); - if (iconPath.isEmpty()) { - m_searchIcon = SmallIcon("unknown"); - } else { - m_searchIcon = QPixmap(iconPath); - } - } - else - { - m_searchIcon = SmallIcon("google"); - } - } - - // Create a bit wider icon with arrow - QPixmap arrowmap = QPixmap(m_searchIcon.width()+5,m_searchIcon.height()+5); - arrowmap.fill(m_searchCombo->lineEdit()->palette().color(m_searchCombo->lineEdit()->backgroundRole())); - QPainter p(&arrowmap); - p.drawPixmap(0, 2, m_searchIcon); - QStyleOption opt; - opt.state = QStyle::State_None; - opt.rect = QRect(arrowmap.width()-6, arrowmap.height()-5, 6, 5); - m_searchCombo->style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &opt, &p, m_searchCombo); - p.end(); - m_searchIcon = arrowmap; - m_searchCombo->setIcon(m_searchIcon); -} - -void SearchBar::showSelectionMenu() +void SearchBar::setSearchBar(QObject *object) { - if (!m_popupMenu) { - KUriFilterData data; - QStringList list; - list << "kurisearchfilter" << "kuriikwsfilter"; - - m_popupMenu = new QMenu(m_searchCombo); - m_popupMenu->setObjectName("search selection menu"); - m_popupMenu->addAction(KIcon("edit-find"), i18n("Find in This Page"), this, SLOT(useFindInThisPage())); - m_popupMenu->addSeparator(); - - int i=-1; - for (QStringList::ConstIterator it = m_searchEngines.begin(); it != m_searchEngines.end(); ++it) { - i++; - KService::Ptr service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(*it)); - if (!service) { - continue; - } - const QString searchProviderPrefix = service->property("Keys").toStringList().first() + delimiter(); - data.setData(searchProviderPrefix + "some keyword"); - - if (KUriFilter::self()->filterUri(data, list)) - { - QIcon icon; - QString iconPath = KStandardDirs::locate("cache", KMimeType::favIconForUrl(data.uri()) + ".png"); - if (iconPath.isEmpty()) { - icon = KIcon("unknown"); - } else { - icon = QPixmap(iconPath); - } - QAction* action = m_popupMenu->addAction(icon, service->name()); - action->setData(qVariantFromValue(i)); - } - } - - m_popupMenu->addSeparator(); - m_popupMenu->addAction(KIcon("preferences-web-browser-shortcuts"), i18n("Select Search Engines..."), - this, SLOT(selectSearchEngines())); - connect(m_popupMenu, SIGNAL(triggered(QAction *)), SLOT(useSearchProvider(QAction *))); - } - m_popupMenu->popup(m_searchCombo->mapToGlobal(QPoint(0, m_searchCombo->height() + 1))); + m_object = object; } -void SearchBar::useFindInThisPage() -{ - m_searchMode = FindInThisPage; - setIcon(); -} -void SearchBar::useSearchProvider(QAction *action) +QObject *SearchBar::getSearchBar() const { - bool ok = false; - const int id = action->data().toInt(&ok); - if(!ok) { - // Not a search engine entry selected - return; - } - m_searchMode = UseSearchProvider; - m_currentEngine = m_searchEngines.at(id); - setIcon(); - m_searchCombo->lineEdit()->selectAll(); + return m_object; } -void SearchBar::selectSearchEngines() -{ - m_process = new KProcess; - *m_process << "kcmshell4" << "ebrowsing"; - - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), SLOT(searchEnginesSelected(int,QProcess::ExitStatus))); - - m_process->start(); - if(!m_process->waitForStarted()) - { - kDebug(1202) << "Couldn't invoke kcmshell"; - delete m_process; - m_process = 0; - } -} - -void SearchBar::searchEnginesSelected(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitCode); - if(exitStatus == QProcess::NormalExit) { - KConfigGroup config(KGlobal::config(), "SearchBar"); - config.writeEntry("CurrentEngine", m_currentEngine); - config.sync(); - configurationChanged(); - } - delete m_process; - m_process = 0; -} - -void SearchBar::configurationChanged() +void SearchBar::clear() { - KConfigGroup config(KSharedConfig::openConfig("kuriikwsfilterrc"), "General"); - const QString engine = config.readEntry("DefaultSearchEngine", "google"); - - QStringList favoriteEngines; - favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia"; - favoriteEngines = config.readEntry("FavoriteSearchEngines", favoriteEngines); - - delete m_popupMenu; - m_popupMenu = 0; - m_searchEngines.clear(); - m_searchEngines << engine; - for (QStringList::ConstIterator it = favoriteEngines.begin(); it != favoriteEngines.end(); ++it) - if(*it!=engine) - m_searchEngines << *it; - - if(engine.isEmpty()) { - m_providerName = "Google"; - } else { - KDesktopFile file("services", "searchproviders/" + engine + ".desktop"); - m_providerName = file.readName(); - } - - config = KConfigGroup(KGlobal::config(), "SearchBar"); - m_searchMode = (SearchModes) config.readEntry("Mode", (int) UseSearchProvider); - m_currentEngine = config.readEntry("CurrentEngine", engine); - - if (m_currentEngine.isEmpty()) - m_currentEngine = "google"; - - setIcon(); + m_lineEdit->setText(QString()); } - -void SearchBar::updateComboVisibility() +void SearchBar::showFind() { - if (!m_part|| m_searchComboAction->associatedWidgets().isEmpty()) + if (!isVisible()) { - m_searchCombo->setPluginActive(false); - m_searchCombo->hide(); - } else { - m_searchCombo->setPluginActive(true); - m_searchCombo->show(); + show(); } + m_lineEdit->setFocus(); + m_lineEdit->selectAll(); } - -void SearchBar::focusSearchbar() -{ - m_searchCombo->setFocus(Qt::ShortcutFocusReason); -} - - - -SearchBarCombo::SearchBarCombo(QWidget *parent) : - KHistoryComboBox(parent), - m_pluginActive(true) -{ - setDuplicatesEnabled(false); - setFixedWidth(180); - connect(this, SIGNAL(cleared()), SLOT(historyCleared())); - - Q_ASSERT(useCompletion()); - - KConfigGroup config(KGlobal::config(), "SearchBar"); - QStringList list = config.readEntry( "History list", QStringList() ); - list.prepend(QString()); // empty item - setHistoryItems(list, true); - Q_ASSERT(currentText().isEmpty()); // KHistoryComboBox calls clearEditText -} - -const QPixmap &SearchBarCombo::icon() const -{ - return m_icon; -} - -void SearchBarCombo::setIcon(const QPixmap &icon) +void SearchBar::resizeEvent(QResizeEvent *event) { - m_icon = icon; - const QString editText = currentText(); - if (count() == 0) { - insertItem(0, m_icon, 0); - } else { - for(int i = 0; i < count(); i++) { - setItemIcon(i, m_icon); - } - } - setEditText(editText); +/* if (event->size().width() != m_widget->width()) + m_widget->resize(event->size().width(), m_widget->height()); + QWidget::resizeEvent(event);*/ } -int SearchBarCombo::findHistoryItem(const QString &searchText) -{ - for(int i = 0; i < count(); i++) { - if (itemText(i) == searchText) { - return i; - } - } - - return -1; -} -void SearchBarCombo::mousePressEvent(QMouseEvent *e) +void SearchBar::frameChanged(int frame) { - QStyleOptionComplex opt; - int x0 = QStyle::visualRect(layoutDirection(), style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxEditField, this), rect()).x(); - - if (e->x() > x0 + 2 && e->x() < lineEdit()->x()) { - emit iconClicked(); - - e->accept(); - } else { - KHistoryComboBox::mousePressEvent(e); - } + if (!m_widget) + return; + m_widget->move(0, frame); + int height = qMax(0, m_widget->y() + m_widget->height()); + setMinimumHeight(height); + setMaximumHeight(height); } -void SearchBarCombo::historyCleared() -{ - setIcon(m_icon); -} -void SearchBarCombo::setPluginActive(bool pluginActive) -{ - m_pluginActive = pluginActive; -} +void SearchBar::slotFindNext() +{} -void SearchBarCombo::show() -{ - if (m_pluginActive) { - KHistoryComboBox::show(); - } -} - -SearchBarCombo::~SearchBarCombo() -{ - KConfigGroup config(KGlobal::config(), "SearchBar"); - config.writeEntry( "History list", historyItems() ); -} +void SearchBar::slotFindPrevious() +{} -#include "searchbar.moc" diff --git a/src/searchbar.h b/src/searchbar.h index e574508b..287363c3 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -2,6 +2,7 @@  *  * This file is a part of the reKonq project  * + * Copyright 2008 Benjamin C. Meyer * Copyright (C) 2008 by Andrea Diamantini  * * @@ -20,82 +21,38 @@ #ifndef SEARCHBAR_H #define SEARCHBAR_H -#include -#include -#include -#include +#include -#include -#include -#include +#include -class SearchBarCombo : public KHistoryComboBox +class SearchBar : public QWidget { Q_OBJECT public: - SearchBarCombo(QWidget *parent); - ~SearchBarCombo(); - const QPixmap &icon() const; - void setIcon(const QPixmap &icon); - int findHistoryItem(const QString &text); + SearchBar(QWidget *parent = 0); + ~SearchBar(); + void setSearchBar(QObject *); + QObject *getSearchBar() const; public slots: - virtual void show(); - -signals: - void iconClicked(); + void clear(); + void showFind(); + void slotFindNext(); + void slotFindPrevious(); protected: - virtual void mousePressEvent(QMouseEvent *e); - -private slots: - void historyCleared(); - -private: - QPixmap m_icon; -}; - - -class SearchBar : public KDialog -{ - Q_OBJECT - -public: - enum SearchModes { FindInThisPage = 0, UseSearchProvider }; - - SearchBar(); - virtual ~SearchBar(); + void resizeEvent(QResizeEvent *event); private slots: - void startSearch(const QString &search); - void setIcon(); - void showSelectionMenu(); - - void useFindInThisPage(); - void useSearchProvider(QAction *); - void selectSearchEngines(); - void searchEnginesSelected(int, QProcess::ExitStatus); - void configurationChanged(); + void frameChanged(int frame); - void updateComboVisibility(); - - void focusSearchbar(); private: - void nextSearchEntry(); - void previousSearchEntry(); - + void initializeSearchWidget(); + QObject *m_object; + QWidget *m_widget; - SearchBarCombo *m_searchCombo; - KAction *m_searchComboAction; - QMenu *m_popupMenu; - QPixmap m_searchIcon; - SearchModes m_searchMode; - QString m_providerName; - bool m_urlEnterLock; - QString m_currentEngine; - QStringList m_searchEngines; - KProcess *m_process; + KLineEdit *m_lineEdit; }; #endif -- cgit v1.2.1 From 529a2cd893434b5e672183015c342cf0b17b49d7 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 13 Nov 2008 16:15:38 +0100 Subject: Adjusted previous/next navigation actions --- src/browsermainwindow.cpp | 25 ++++++++++++++++++++----- src/browsermainwindow.h | 7 ++++++- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 81784a62..717031a5 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -289,14 +289,14 @@ void BrowserMainWindow::setupMenu() viewMenu->addSeparator(); m_stop = (KAction *) viewMenu->addAction( KIcon( "process-stop" ), i18n("&Stop") ); - QList shortcuts; - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); - shortcuts.append(Qt::Key_Escape); - m_stop->setShortcuts(shortcuts); +// QList shortcuts; +// shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); +// shortcuts.append(Qt::Key_Escape); + m_stop->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); m_tabWidget->addWebAction(m_stop, QWebPage::Stop); m_reload = (KAction *) viewMenu->addAction( KIcon("view-refresh"), i18n("Reload Page") ); - m_reload->setShortcuts(QKeySequence::Refresh); + m_reload->setShortcut(QKeySequence::Refresh); m_tabWidget->addWebAction(m_reload, QWebPage::Reload); viewMenu->addAction( i18n("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); @@ -379,11 +379,13 @@ void BrowserMainWindow::setupToolBar() m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); m_historyBack->setMenu(m_historyBackMenu); + connect(m_historyBack, SIGNAL( triggered() ), this, SLOT( slotOpenPrevious() ) ); connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); m_navigationBar->addAction(m_historyBack); m_historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); + connect(m_historyForward, SIGNAL( triggered() ), this, SLOT( slotOpenNext() ) ); m_navigationBar->addAction(m_historyForward); m_stopReload = new KAction( KIcon("view-refresh"), i18n("Reload"), this); @@ -918,7 +920,20 @@ void BrowserMainWindow::slotOpenActionUrl(QAction *action) } +void BrowserMainWindow::slotOpenPrevious() +{ + QWebHistory *history = currentTab()->history(); + if ( history->canGoBack() ) + history->goToItem( history->backItem() ); +} + +void BrowserMainWindow::slotOpenNext() +{ + QWebHistory *history = currentTab()->history(); + if ( history->canGoForward() ) + history->goToItem( history->forwardItem() ); +} void BrowserMainWindow::geometryChangeRequested(const QRect &geometry) { diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index faf98e93..64962c58 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -105,7 +105,12 @@ private slots: void slotAboutToShowBackMenu(); void slotAboutToShowWindowMenu(); + + // history related void slotOpenActionUrl(QAction *action); + void slotOpenPrevious(); + void slotOpenNext(); + void slotShowWindow(); void slotSwapFocus(); @@ -132,7 +137,7 @@ private: KMenu *m_windowMenu; KAction *m_stop; - QAction *m_reload; + KAction *m_reload; KAction *m_stopReload; KAction *m_goHome; KAction *m_viewStatusbar; -- cgit v1.2.1 From 5944fa01d76b7624bb88672c48dd4c597e3c4f02 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 14 Nov 2008 12:12:35 +0100 Subject: searchbar --> findbar Yes, I know it's a search bar and finding is not granted. But I need to distingue between this and the "other" searchbar.. --- src/CMakeLists.txt | 2 +- src/browsermainwindow.cpp | 12 ++-- src/browsermainwindow.h | 7 +-- src/findbar.cpp | 125 ++++++++++++++++++++++++++++++++++++++++ src/findbar.h | 53 +++++++++++++++++ src/findwidget.cpp | 58 ------------------- src/findwidget.h | 33 ----------- src/searchbar.cpp | 141 ---------------------------------------------- src/searchbar.h | 58 ------------------- 9 files changed, 188 insertions(+), 301 deletions(-) create mode 100644 src/findbar.cpp create mode 100644 src/findbar.h delete mode 100644 src/findwidget.cpp delete mode 100644 src/findwidget.h delete mode 100644 src/searchbar.cpp delete mode 100644 src/searchbar.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a30af320..2f4ebb9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,7 @@ SET( rekonq_SRCS modelmenu.cpp networkaccessmanager.cpp searchlineedit.cpp - searchbar.cpp + findbar.cpp findwidget.cpp settings.cpp squeezelabel.cpp diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 717031a5..46510384 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -82,9 +82,9 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) addToolBarBreak(); layout->addWidget(m_tabWidget); - // Search Bar - m_searchBar = new SearchBar(centralWidget); - layout->addWidget(m_searchBar); + // Find Bar + m_findBar = new FindBar(centralWidget); + layout->addWidget(m_findBar); centralWidget->setLayout(layout); setCentralWidget(centralWidget); @@ -268,7 +268,7 @@ void BrowserMainWindow::setupMenu() editMenu->addSeparator(); - editMenu->addAction( KStandardAction::find(this, SLOT( slotViewSearchBar() ) , this ) ); + editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); editMenu->addAction( KStandardAction::findNext(this, SLOT( slotEditFindNext() ) , this ) ); editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotEditFindPrevious() ) , this ) ); @@ -671,9 +671,9 @@ bool ok; m_lastSearch = findWidg->*/ } -void BrowserMainWindow::slotViewSearchBar() +void BrowserMainWindow::slotViewFindBar() { - m_searchBar->show(); + m_findBar->show(); } void BrowserMainWindow::slotEditFindNext() diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 64962c58..cc206626 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -23,7 +23,7 @@ #define BROWSERMAINWINDOW_H // Local Includes -#include "searchbar.h" +#include "findbar.h" // KDE Includes #include @@ -96,7 +96,7 @@ private slots: void slotViewStatusbar(); void slotViewPageSource(); void slotViewFullScreen(bool enable); - void slotViewSearchBar(); + void slotViewFindBar(); void slotWebSearch(); void slotToggleInspector(bool enable); @@ -133,7 +133,6 @@ private: QAction *m_historyBack; KMenu *m_historyBackMenu; QAction *m_historyForward; -// KMenu *m_historyForwardMenu; KMenu *m_windowMenu; KAction *m_stop; @@ -147,7 +146,7 @@ private: KIcon m_reloadIcon; KIcon m_stopIcon; - SearchBar *m_searchBar; + FindBar *m_findBar; QString m_lastSearch; KBookmarkMenu* m_bookmarkMenu; diff --git a/src/findbar.cpp b/src/findbar.cpp new file mode 100644 index 00000000..ae64b7f6 --- /dev/null +++ b/src/findbar.cpp @@ -0,0 +1,125 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#include "findbar.h" +#include "moc_findbar.cpp" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +FindBar::FindBar(QWidget *parent) + : QWidget(parent) + , m_lineEdit(0) +{ + initializeFindWidget(); + + // we start off hidden + setMaximumHeight(0); +// m_widget->setGeometry(0, -1 * m_widget->height(), m_widget->width(), m_widget->height()); + hide(); + + new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(hide())); +} + +FindBar::~FindBar() +{ + delete m_lineEdit; +} + + +void FindBar::initializeFindWidget() +{ + QHBoxLayout *layout = new QHBoxLayout(); + + KToolBar *bar1 = new KToolBar(this); + bar1->addAction( KStandardAction::close(this, SLOT( hide() ) , this ) ); + layout->addWidget( bar1 ); + + QLabel *label = new QLabel("Find: "); + layout->addWidget( label ); + + m_lineEdit = new KLineEdit(); + connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); + connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); + layout->addWidget( m_lineEdit ); + + KToolBar *bar2 = new KToolBar(this); + bar2->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); + bar2->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); + layout->addWidget( bar2 ); + + layout->addStretch(); + + setLayout(layout); +} + + + +void FindBar::clear() +{ + m_lineEdit->setText(QString()); +} + + +void FindBar::showFind() +{ + if (!isVisible()) + { + show(); + } + m_lineEdit->setFocus(); + m_lineEdit->selectAll(); +} + + +void FindBar::resizeEvent(QResizeEvent *event) +{ +/* if (event->size().width() != m_widget->width()) + m_widget->resize(event->size().width(), m_widget->height()); + QWidget::resizeEvent(event);*/ +} + + +void FindBar::frameChanged(int frame) +{ +/* if (!m_widget) + return; + m_widget->move(0, frame); + int height = qMax(0, m_widget->y() + m_widget->height()); + setMinimumHeight(height); + setMaximumHeight(height);*/ +} + + +void FindBar::slotFindNext() +{} + +void FindBar::slotFindPrevious() +{} + diff --git a/src/findbar.h b/src/findbar.h new file mode 100644 index 00000000..214a06e2 --- /dev/null +++ b/src/findbar.h @@ -0,0 +1,53 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef FINDBAR_H +#define FINDBAR_H + +#include + +#include + +class FindBar : public QWidget +{ + Q_OBJECT + +public: + FindBar(QWidget *parent = 0); + ~FindBar(); + +public slots: + void clear(); + void showFind(); + void slotFindNext(); + void slotFindPrevious(); + +protected: + void resizeEvent(QResizeEvent *event); + +private slots: + void frameChanged(int frame); + +private: + void initializeFindWidget(); + + KLineEdit *m_lineEdit; +}; + +#endif diff --git a/src/findwidget.cpp b/src/findwidget.cpp deleted file mode 100644 index 4eb10e6b..00000000 --- a/src/findwidget.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#include "findwidget.h" - -#include -#include - -#include -#include -#include -#include - -FindWidget::FindWidget(QWidget * parent) : QWidget(parent) -{ - QHBoxLayout *layout = new QHBoxLayout(); - - KToolBar *bar1 = new KToolBar(this); - bar1->addAction( KStandardAction::close(this, SLOT( searchNow() ) , this ) ); - layout->addWidget( bar1 ); - - QLabel *label = new QLabel("Find: "); - layout->addWidget( label ); - - KLineEdit *findLineEdit = new KLineEdit(); - layout->addWidget( findLineEdit ); - - KToolBar *bar2 = new KToolBar(this); - bar2->addAction( KStandardAction::findNext(this, SLOT( searchNow() ) , this ) ); - bar2->addAction( KStandardAction::findPrev(this, SLOT( searchNow() ) , this ) ); - layout->addWidget( bar2 ); - - layout->addStretch(); - - setLayout(layout); -} - -QString FindWidget::searchNow() -{ - QString prova("adjam"); - return prova; -} diff --git a/src/findwidget.h b/src/findwidget.h deleted file mode 100644 index 5d8b7b28..00000000 --- a/src/findwidget.h +++ /dev/null @@ -1,33 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef FINDWIDGET_H -#define FINDWIDGET_H - -#include - -class FindWidget : public QWidget -{ -public: - FindWidget(QWidget * parent = 0); - - QString searchNow(); -}; - -#endif diff --git a/src/searchbar.cpp b/src/searchbar.cpp deleted file mode 100644 index b0e91fa9..00000000 --- a/src/searchbar.cpp +++ /dev/null @@ -1,141 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright 2008 Benjamin C. Meyer - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#include "searchbar.h" -#include "moc_searchbar.cpp" - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -SearchBar::SearchBar(QWidget *parent) - : QWidget(parent) - , m_object(0) - , m_widget(0) - , m_lineEdit(0) -{ - initializeSearchWidget(); - - // we start off hidden - setMaximumHeight(0); -// m_widget->setGeometry(0, -1 * m_widget->height(), m_widget->width(), m_widget->height()); - hide(); - - new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(hide())); -} - -SearchBar::~SearchBar() -{ - delete m_object; - delete m_widget; - delete m_lineEdit; -} - - -void SearchBar::initializeSearchWidget() -{ - QHBoxLayout *layout = new QHBoxLayout(); - - KToolBar *bar1 = new KToolBar(this); - bar1->addAction( KStandardAction::close(this, SLOT( hide() ) , this ) ); - layout->addWidget( bar1 ); - - QLabel *label = new QLabel("Find: "); - layout->addWidget( label ); - - m_lineEdit = new KLineEdit(); - connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); - connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); - layout->addWidget( m_lineEdit ); - - KToolBar *bar2 = new KToolBar(this); - bar2->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - bar2->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); - layout->addWidget( bar2 ); - - layout->addStretch(); - - setLayout(layout); -} - - -void SearchBar::setSearchBar(QObject *object) -{ - m_object = object; -} - - -QObject *SearchBar::getSearchBar() const -{ - return m_object; -} - - -void SearchBar::clear() -{ - m_lineEdit->setText(QString()); -} - - -void SearchBar::showFind() -{ - if (!isVisible()) - { - show(); - } - m_lineEdit->setFocus(); - m_lineEdit->selectAll(); -} - - -void SearchBar::resizeEvent(QResizeEvent *event) -{ -/* if (event->size().width() != m_widget->width()) - m_widget->resize(event->size().width(), m_widget->height()); - QWidget::resizeEvent(event);*/ -} - - -void SearchBar::frameChanged(int frame) -{ - if (!m_widget) - return; - m_widget->move(0, frame); - int height = qMax(0, m_widget->y() + m_widget->height()); - setMinimumHeight(height); - setMaximumHeight(height); -} - - -void SearchBar::slotFindNext() -{} - -void SearchBar::slotFindPrevious() -{} - diff --git a/src/searchbar.h b/src/searchbar.h deleted file mode 100644 index 287363c3..00000000 --- a/src/searchbar.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright 2008 Benjamin C. Meyer - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef SEARCHBAR_H -#define SEARCHBAR_H - -#include - -#include - -class SearchBar : public QWidget -{ - Q_OBJECT - -public: - SearchBar(QWidget *parent = 0); - ~SearchBar(); - void setSearchBar(QObject *); - QObject *getSearchBar() const; - -public slots: - void clear(); - void showFind(); - void slotFindNext(); - void slotFindPrevious(); - -protected: - void resizeEvent(QResizeEvent *event); - -private slots: - void frameChanged(int frame); - -private: - void initializeSearchWidget(); - QObject *m_object; - QWidget *m_widget; - - KLineEdit *m_lineEdit; -}; - -#endif -- cgit v1.2.1 From 47a69e593d2d816374d263076b87a9ffb987459a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 17 Nov 2008 00:42:18 +0100 Subject: Ported search bar. 1st implementation. For Now, just Google Search. --- src/CMakeLists.txt | 5 +- src/browsermainwindow.cpp | 19 +++---- src/browsermainwindow.h | 6 +- src/searchbar.cpp | 62 +++++++++++++++++++++ src/searchbar.h | 52 +++++++++++++++++ src/toolbarsearch.cpp | 139 ---------------------------------------------- src/toolbarsearch.h | 63 --------------------- src/urlbar.cpp | 25 +++++++++ src/urlbar.h | 28 ++++++++++ src/urllineedit.cpp | 6 +- 10 files changed, 184 insertions(+), 221 deletions(-) create mode 100644 src/searchbar.cpp create mode 100644 src/searchbar.h delete mode 100644 src/toolbarsearch.cpp delete mode 100644 src/toolbarsearch.h create mode 100644 src/urlbar.cpp create mode 100644 src/urlbar.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f4ebb9b..edcfd561 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,11 +11,10 @@ SET( rekonq_SRCS networkaccessmanager.cpp searchlineedit.cpp findbar.cpp - findwidget.cpp + searchbar.cpp settings.cpp squeezelabel.cpp - tabwidget.cpp - toolbarsearch.cpp + tabwidget.cpp urllineedit.cpp webview.cpp main.cpp diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 46510384..4ea1d444 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -27,7 +27,7 @@ #include "history.h" #include "settings.h" #include "tabwidget.h" -#include "toolbarsearch.h" +// #include "toolbarsearch.h" #include "webview.h" // UI Includes @@ -289,9 +289,6 @@ void BrowserMainWindow::setupMenu() viewMenu->addSeparator(); m_stop = (KAction *) viewMenu->addAction( KIcon( "process-stop" ), i18n("&Stop") ); -// QList shortcuts; -// shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Period)); -// shortcuts.append(Qt::Key_Escape); m_stop->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); m_tabWidget->addWebAction(m_stop, QWebPage::Stop); @@ -397,10 +394,12 @@ void BrowserMainWindow::setupToolBar() m_navigationBar->addWidget(m_tabWidget->lineEditStack()); - m_toolbarSearch = new ToolbarSearch(m_navigationBar); - m_navigationBar->addWidget(m_toolbarSearch); - - connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); + m_searchBar = new SearchBar(m_navigationBar); + m_navigationBar->addWidget(m_searchBar); + connect(m_searchBar, SIGNAL(search(const QUrl&)), this, SLOT(loadUrl(const QUrl&))); +// m_toolbarSearch = new ToolbarSearch(m_navigationBar); +// m_navigationBar->addWidget(m_toolbarSearch); +// connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); } @@ -766,8 +765,8 @@ void BrowserMainWindow::slotHome() void BrowserMainWindow::slotWebSearch() { - m_toolbarSearch->lineEdit()->selectAll(); - m_toolbarSearch->lineEdit()->setFocus(); +// m_toolbarSearch->lineEdit()->selectAll(); +// m_toolbarSearch->lineEdit()->setFocus(); } diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index cc206626..c5db7bba 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -24,6 +24,7 @@ // Local Includes #include "findbar.h" +#include "searchbar.h" // KDE Includes #include @@ -40,7 +41,7 @@ class AutoSaver; class QWebFrame; class TabWidget; -class ToolbarSearch; +// class ToolbarSearch; class WebView; /*! @@ -126,7 +127,8 @@ private: private: KToolBar *m_navigationBar; - ToolbarSearch *m_toolbarSearch; +// ToolbarSearch *m_toolbarSearch; + SearchBar *m_searchBar; TabWidget *m_tabWidget; AutoSaver *m_autoSaver; diff --git a/src/searchbar.cpp b/src/searchbar.cpp new file mode 100644 index 00000000..deb8d631 --- /dev/null +++ b/src/searchbar.cpp @@ -0,0 +1,62 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// Local Includes +#include "searchbar.h" +#include "searchbar.moc" + +// Qt Includes +#include + +SearchBar::SearchBar(QWidget *parent) : + QWidget(parent), + m_lineEdit(0) +{ + m_lineEdit = new KLineEdit(this); + m_lineEdit->setClearButtonShown( true ); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(m_lineEdit); + setLayout(layout); + + connect( lineEdit() , SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); +} + +SearchBar::~SearchBar() +{ +} + +void SearchBar::searchNow() +{ + QString searchText = m_lineEdit->text(); + + QUrl url(QLatin1String("http://www.google.com/search")); + url.addQueryItem(QLatin1String("q"), searchText); + url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); + url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); + url.addQueryItem(QLatin1String("client"), QLatin1String("reKonq")); + emit search(url); + +} + +KLineEdit *SearchBar::lineEdit() +{ + return m_lineEdit; +} + diff --git a/src/searchbar.h b/src/searchbar.h new file mode 100644 index 00000000..40235891 --- /dev/null +++ b/src/searchbar.h @@ -0,0 +1,52 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +#ifndef SEARCHBAR_H +#define SEARCHBAR_H + +// KDE Includes +#include + +// Qt Includes +#include +#include + +class SearchBar : public QWidget +{ +Q_OBJECT + +public: + SearchBar(QWidget *parent = 0); + ~SearchBar(); + + KLineEdit *lineEdit(); + +public slots: + void searchNow(); + +private: + KLineEdit *m_lineEdit; + +signals: + void search(const QUrl &url); + +}; + +#endif diff --git a/src/toolbarsearch.cpp b/src/toolbarsearch.cpp deleted file mode 100644 index 4fd3aa51..00000000 --- a/src/toolbarsearch.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -// Local Includes -#include "toolbarsearch.h" -#include "autosaver.h" - -// Qt Includes -#include -#include -#include -#include -#include -#include - -/* - ToolbarSearch is a very basic search widget that also contains a small history. - Searches are turned into urls that use Google to perform search - */ -ToolbarSearch::ToolbarSearch(QWidget *parent) - : SearchLineEdit(parent) - , m_autosaver(new AutoSaver(this)) - , m_maxSavedSearches(10) - , m_stringListModel(new QStringListModel(this)) -{ - QMenu *m = menu(); - connect(m, SIGNAL(aboutToShow()), this, SLOT(aboutToShowMenu())); - connect(m, SIGNAL(triggered(QAction*)), this, SLOT(triggeredMenuAction(QAction*))); - - QCompleter *completer = new QCompleter(m_stringListModel, this); - completer->setCompletionMode(QCompleter::InlineCompletion); - lineEdit()->setCompleter(completer); - - connect(lineEdit(), SIGNAL(returnPressed()), SLOT(searchNow())); - setInactiveText("Google"); - load(); -} - -ToolbarSearch::~ToolbarSearch() -{ - m_autosaver->saveIfNeccessary(); -} - -void ToolbarSearch::save() -{ - QSettings settings; - settings.beginGroup(QLatin1String("toolbarsearch")); - settings.setValue(QLatin1String("recentSearches"), m_stringListModel->stringList()); - settings.setValue(QLatin1String("maximumSaved"), m_maxSavedSearches); - settings.endGroup(); -} - -void ToolbarSearch::load() -{ - QSettings settings; - settings.beginGroup(QLatin1String("toolbarsearch")); - QStringList list = settings.value(QLatin1String("recentSearches")).toStringList(); - m_maxSavedSearches = settings.value(QLatin1String("maximumSaved"), m_maxSavedSearches).toInt(); - m_stringListModel->setStringList(list); - settings.endGroup(); -} - -void ToolbarSearch::searchNow() -{ - QString searchText = lineEdit()->text(); - QStringList newList = m_stringListModel->stringList(); - if (newList.contains(searchText)) - newList.removeAt(newList.indexOf(searchText)); - newList.prepend(searchText); - if (newList.size() >= m_maxSavedSearches) - newList.removeLast(); - - QWebSettings *globalSettings = QWebSettings::globalSettings(); - if (!globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { - m_stringListModel->setStringList(newList); - m_autosaver->changeOccurred(); - } - - QUrl url(QLatin1String("http://www.google.com/search")); - url.addQueryItem(QLatin1String("q"), searchText); - url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); - url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); - url.addQueryItem(QLatin1String("client"), QLatin1String("reKonq")); - emit search(url); -} - -void ToolbarSearch::aboutToShowMenu() -{ - lineEdit()->selectAll(); - QMenu *m = menu(); - m->clear(); - QStringList list = m_stringListModel->stringList(); - if (list.isEmpty()) { - m->addAction( tr("No Recent Searches") ); - return; - } - - QAction *recent = m->addAction( tr("Recent Searches") ); - recent->setEnabled(false); - for (int i = 0; i < list.count(); ++i) { - QString text = list.at(i); - m->addAction(text)->setData(text); - } - m->addSeparator(); - m->addAction( tr("Clear Recent Searches"), this, SLOT(clear())); -} - -void ToolbarSearch::triggeredMenuAction(QAction *action) -{ - QVariant v = action->data(); - if (v.canConvert()) { - QString text = v.toString(); - lineEdit()->setText(text); - searchNow(); - } -} - -void ToolbarSearch::clear() -{ - m_stringListModel->setStringList(QStringList()); - m_autosaver->changeOccurred();; -} diff --git a/src/toolbarsearch.h b/src/toolbarsearch.h deleted file mode 100644 index 81f06180..00000000 --- a/src/toolbarsearch.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef TOOLBARSEARCH_H -#define TOOLBARSEARCH_H - -#include "searchlineedit.h" - -QT_BEGIN_NAMESPACE -class QUrl; -class QAction; -class QStringListModel; -QT_END_NAMESPACE - -class AutoSaver; - -class ToolbarSearch : public SearchLineEdit -{ - Q_OBJECT - -signals: - void search(const QUrl &url); - -public: - ToolbarSearch(QWidget *parent = 0); - ~ToolbarSearch(); - -public slots: - void clear(); - void searchNow(); - -private slots: - void save(); - void aboutToShowMenu(); - void triggeredMenuAction(QAction *action); - -private: - void load(); - - AutoSaver *m_autosaver; - int m_maxSavedSearches; - QStringListModel *m_stringListModel; -}; - -#endif // TOOLBARSEARCH_H - diff --git a/src/urlbar.cpp b/src/urlbar.cpp new file mode 100644 index 00000000..62b28614 --- /dev/null +++ b/src/urlbar.cpp @@ -0,0 +1,25 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + + + + + + diff --git a/src/urlbar.h b/src/urlbar.h new file mode 100644 index 00000000..13c4c320 --- /dev/null +++ b/src/urlbar.h @@ -0,0 +1,28 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef URLBAR_H +#define URLBAR_H + + + + + + +#endif diff --git a/src/urllineedit.cpp b/src/urllineedit.cpp index bd48bb03..88ce28c4 100644 --- a/src/urllineedit.cpp +++ b/src/urllineedit.cpp @@ -64,10 +64,8 @@ ExLineEdit::ExLineEdit(QWidget *parent) // clearButton m_clearButton = new ClearButton(this); - connect(m_clearButton, SIGNAL(clicked()), - m_lineEdit, SLOT(clear())); - connect(m_lineEdit, SIGNAL(textChanged(const QString&)), - m_clearButton, SLOT(textChanged(const QString&))); + connect(m_clearButton, SIGNAL(clicked()), m_lineEdit, SLOT(clear())); + connect(m_lineEdit, SIGNAL(textChanged(const QString&)), m_clearButton, SLOT(textChanged(const QString&))); } void ExLineEdit::setLeftWidget(QWidget *widget) -- cgit v1.2.1 From 516a513d7a0ef2f07ffe43fc8a076a3e8f1e0564 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 21 Nov 2008 01:38:10 +0100 Subject: QSettings --> KConfig --- src/settings.cpp | 236 +++++++++++++++++++++++++++++-------------------------- src/settings.h | 15 +++- src/settings.ui | 134 +++---------------------------- 3 files changed, 149 insertions(+), 236 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 9aa2963d..d23e7def 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -18,7 +18,12 @@  *  * ============================================================ */ + +// Local Includes #include "settings.h" +#include "settings.moc" + +// #include "ui_settings.h" #include "browserapplication.h" #include "browsermainwindow.h" @@ -27,19 +32,37 @@ #include "networkaccessmanager.h" #include "webview.h" -#include -#include -#include +// KDE Includes +#include +#include + +// Qt Includes +#include +#include SettingsDialog::SettingsDialog(QWidget *parent) - : QDialog(parent) + : KDialog(parent), + widget(0) { - setupUi(this); - connect(exceptionsButton, SIGNAL(clicked()), this, SLOT(showExceptions())); - connect(setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); - connect(cookiesButton, SIGNAL(clicked()), this, SLOT(showCookies())); - connect(standardFontButton, SIGNAL(clicked()), this, SLOT(chooseFont())); - connect(fixedFontButton, SIGNAL(clicked()), this, SLOT(chooseFixedFont())); + widget = new QWidget; + + setupUi(widget); + + setMainWidget(widget); + + setWindowTitle( i18n("Setting reKonq..") ); + setButtons( KDialog::Ok | KDialog::Close | KDialog::Apply ); + setModal(true); + + connect(this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) ); + connect(this, SIGNAL( closeClicked() ), this, SLOT( close() ) ); + connect(this, SIGNAL( applyClicked() ), this, SLOT( slotApply() ) ); + + connect(exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); + connect(setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); + connect(cookiesButton, SIGNAL(clicked()), this, SLOT( showCookies() ) ); + connect(standardFontButton, SIGNAL(clicked()), this, SLOT( chooseFont() ) ); + connect(fixedFontButton, SIGNAL(clicked()), this, SLOT( chooseFixedFont() ) ); loadDefaults(); loadFromSettings(); @@ -66,60 +89,53 @@ void SettingsDialog::loadDefaults() void SettingsDialog::loadFromSettings() { - QSettings settings; - settings.beginGroup(QLatin1String("MainWindow")); - QString defaultHome = QLatin1String("http://www.trolltech.com"); - homeLineEdit->setText(settings.value(QLatin1String("home"), defaultHome).toString()); - settings.endGroup(); - - settings.beginGroup(QLatin1String("history")); - int historyExpire = settings.value(QLatin1String("historyExpire")).toInt(); - int idx = 0; - switch (historyExpire) { - case 1: idx = 0; break; - case 7: idx = 1; break; - case 14: idx = 2; break; - case 30: idx = 3; break; - case 365: idx = 4; break; - case -1: idx = 5; break; - default: - idx = 5; + KConfig config("rekonqrc"); + KConfigGroup group1 = config.group("Global Settings"); + + QString defaultHome = QString("http://www.kde.org"); + homeLineEdit->setText( group1.readEntry(QString("home"), defaultHome) ); + + int historyExpire = group1.readEntry( QString("historyExpire"), QString().toInt() ); + int idx = 0; + switch (historyExpire) + { + case 1: idx = 0; break; + case 7: idx = 1; break; + case 14: idx = 2; break; + case 30: idx = 3; break; + case 365: idx = 4; break; + case -1: idx = 5; break; + default: idx = 5; } expireHistory->setCurrentIndex(idx); - settings.endGroup(); - settings.beginGroup(QLatin1String("downloadmanager")); - QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), downloadsLocation->text()).toString(); + QString downloadDirectory = group1.readEntry( QString("downloadDirectory") , QString() ); downloadsLocation->setText(downloadDirectory); - settings.endGroup(); - settings.beginGroup(QLatin1String("general")); - openLinksIn->setCurrentIndex(settings.value(QLatin1String("openLinksIn"), openLinksIn->currentIndex()).toInt()); + openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), openLinksIn->currentIndex() ) ); - settings.endGroup(); // Appearance - settings.beginGroup(QLatin1String("websettings")); - fixedFont = qVariantValue(settings.value(QLatin1String("fixedFont"), fixedFont)); - standardFont = qVariantValue(settings.value(QLatin1String("standardFont"), standardFont)); + KConfigGroup group2 = config.group("Appearance Settings"); + + fixedFont = group2.readEntry( QString("fixedFont"), fixedFont ); + standardFont = group2.readEntry( QString("standardFont"), standardFont ); standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); - enableJavascript->setChecked(settings.value(QLatin1String("enableJavascript"), enableJavascript->isChecked()).toBool()); - enablePlugins->setChecked(settings.value(QLatin1String("enablePlugins"), enablePlugins->isChecked()).toBool()); - userStyleSheet->setText(settings.value(QLatin1String("userStyleSheet")).toUrl().toString()); - settings.endGroup(); + enableJavascript->setChecked( group2.readEntry( QString("enableJavascript"), enableJavascript->isChecked() ) ); + enablePlugins->setChecked( group2.readEntry( QString("enablePlugins"), enablePlugins->isChecked() ) ); // Privacy - settings.beginGroup(QLatin1String("cookies")); + KConfigGroup group3 = config.group("Privacy Settings"); CookieJar *jar = BrowserApplication::cookieJar(); - QByteArray value = settings.value(QLatin1String("acceptCookies"), QLatin1String("AcceptOnlyFromSitesNavigatedTo")).toByteArray(); + QString value = group3.readEntry( QString("acceptCookies"), QString("AcceptOnlyFromSitesNavigatedTo") ) ; QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); - CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue(value) == -1 ? + CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? CookieJar::AcceptOnlyFromSitesNavigatedTo : - static_cast(acceptPolicyEnum.keyToValue(value)); + static_cast(acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) ); switch(acceptCookies) { case CookieJar::AcceptAlways: acceptCombo->setCurrentIndex(0); @@ -132,11 +148,11 @@ void SettingsDialog::loadFromSettings() break; } - value = settings.value(QLatin1String("keepCookiesUntil"), QLatin1String("Expire")).toByteArray(); + value = group3.readEntry( QString("keepCookiesUntil"), QString("Expire") ); QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); - CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue(value) == -1 ? + CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? CookieJar::KeepUntilExpire : - static_cast(keepPolicyEnum.keyToValue(value)); + static_cast(keepPolicyEnum.keyToValue( value.toLocal8Bit() ) ); switch(keepCookies) { case CookieJar::KeepUntilExpire: keepUntilCombo->setCurrentIndex(0); @@ -148,32 +164,28 @@ void SettingsDialog::loadFromSettings() keepUntilCombo->setCurrentIndex(2); break; } - settings.endGroup(); - // Proxy - settings.beginGroup(QLatin1String("proxy")); - proxySupport->setChecked(settings.value(QLatin1String("enabled"), false).toBool()); - proxyType->setCurrentIndex(settings.value(QLatin1String("type"), 0).toInt()); - proxyHostName->setText(settings.value(QLatin1String("hostName")).toString()); - proxyPort->setValue(settings.value(QLatin1String("port"), 1080).toInt()); - proxyUserName->setText(settings.value(QLatin1String("userName")).toString()); - proxyPassword->setText(settings.value(QLatin1String("password")).toString()); - settings.endGroup(); + KConfigGroup group4 = config.group("Proxy Settings"); + + proxySupport->setChecked( group4.readEntry( QString("enabled"), false ) ); + proxyType->setCurrentIndex( group4.readEntry( QString("type"), 0) ); + proxyHostName->setText( group4.readEntry( QString("hostName"), QString() ) ); + proxyPort->setValue( group4.readEntry( QString("port"), QString().toInt() ) ); + proxyUserName->setText( group4.readEntry( QString("userName") , QString() ) ); + proxyPassword->setText( group4.readEntry( QString("password") , QString() ) ); + } void SettingsDialog::saveToSettings() { - QSettings settings; - settings.beginGroup(QLatin1String("MainWindow")); - settings.setValue(QLatin1String("home"), homeLineEdit->text()); - settings.endGroup(); + KConfig config("rekonqrc"); + KConfigGroup group1 = config.group("Global Settings"); + + group1.writeEntry(QString("home"), homeLineEdit->text() ); + group1.writeEntry(QString("openLinksIn"), openLinksIn->currentIndex() ); + group1.writeEntry(QString("downloadDirectory"), downloadsLocation->text() ); - settings.beginGroup(QLatin1String("general")); - settings.setValue(QLatin1String("openLinksIn"), openLinksIn->currentIndex()); - settings.endGroup(); - - settings.beginGroup(QLatin1String("history")); int historyExpire = expireHistory->currentIndex(); int idx = -1; switch (historyExpire) { @@ -184,24 +196,15 @@ void SettingsDialog::saveToSettings() case 4: idx = 365; break; case 5: idx = -1; break; } - settings.setValue(QLatin1String("historyExpire"), idx); - settings.endGroup(); + group1.writeEntry(QString("historyExpire"), idx ); - // Appearance - settings.beginGroup(QLatin1String("websettings")); - settings.setValue(QLatin1String("fixedFont"), fixedFont); - settings.setValue(QLatin1String("standardFont"), standardFont); - settings.setValue(QLatin1String("enableJavascript"), enableJavascript->isChecked()); - settings.setValue(QLatin1String("enablePlugins"), enablePlugins->isChecked()); - QString userStyleSheetString = userStyleSheet->text(); - if (QFile::exists(userStyleSheetString)) - settings.setValue(QLatin1String("userStyleSheet"), QUrl::fromLocalFile(userStyleSheetString)); - else - settings.setValue(QLatin1String("userStyleSheet"), QUrl(userStyleSheetString)); - settings.endGroup(); - - //Privacy - settings.beginGroup(QLatin1String("cookies")); + KConfigGroup group2 = config.group("Appearance Settings"); + group2.writeEntry(QString("fixedFont"),fixedFont); + group2.writeEntry(QString("standardFont"), standardFont); + + KConfigGroup group3 = config.group("Privacy Settings"); + group3.writeEntry(QString("enableJavascript"), enableJavascript->isChecked() ); + group3.writeEntry(QString("enablePlugins"), enablePlugins->isChecked() ); CookieJar::KeepPolicy keepCookies; switch(acceptCombo->currentIndex()) { @@ -218,7 +221,7 @@ void SettingsDialog::saveToSettings() } CookieJar *jar = BrowserApplication::cookieJar(); QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); - settings.setValue(QLatin1String("acceptCookies"), QLatin1String(acceptPolicyEnum.valueToKey(keepCookies))); + group3.writeEntry(QString("acceptCookies"), QString(acceptPolicyEnum.valueToKey(keepCookies) ) ); CookieJar::KeepPolicy keepPolicy; switch(keepUntilCombo->currentIndex()) { @@ -235,31 +238,26 @@ void SettingsDialog::saveToSettings() } QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); - settings.setValue(QLatin1String("keepCookiesUntil"), QLatin1String(keepPolicyEnum.valueToKey(keepPolicy))); + group3.writeEntry(QString("keepCookiesUntil"), QString(keepPolicyEnum.valueToKey(keepPolicy) ) ); - settings.endGroup(); + + KConfigGroup group4 = config.group("Proxy Settings"); + group4.writeEntry(QString("enabled"), proxySupport->isChecked() ); + group4.writeEntry(QString("type"), proxyType->currentIndex() ); + group4.writeEntry(QString("hostName"), proxyHostName->text() ); + group4.writeEntry(QString("port"), proxyPort->text() ); + group4.writeEntry(QString("userName"), proxyUserName->text() ); + group4.writeEntry(QString("password"), proxyPassword->text() ); - // proxy - settings.beginGroup(QLatin1String("proxy")); - settings.setValue(QLatin1String("enabled"), proxySupport->isChecked()); - settings.setValue(QLatin1String("type"), proxyType->currentIndex()); - settings.setValue(QLatin1String("hostName"), proxyHostName->text()); - settings.setValue(QLatin1String("port"), proxyPort->text()); - settings.setValue(QLatin1String("userName"), proxyUserName->text()); - settings.setValue(QLatin1String("password"), proxyPassword->text()); - settings.endGroup(); + config.sync(); + // --- BrowserApplication::instance()->loadSettings(); BrowserApplication::networkAccessManager()->loadSettings(); BrowserApplication::cookieJar()->loadSettings(); BrowserApplication::historyManager()->loadSettings(); } -void SettingsDialog::accept() -{ - saveToSettings(); - QDialog::accept(); -} void SettingsDialog::showCookies() { @@ -275,21 +273,24 @@ void SettingsDialog::showExceptions() void SettingsDialog::chooseFont() { - bool ok; - QFont font = QFontDialog::getFont(&ok, standardFont, this); - if ( ok ) { - standardFont = font; - standardLabel->setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize())); + QFont myFont; + int result = KFontDialog::getFont( myFont ); + if ( result == KFontDialog::Accepted ) + { + standardFont = myFont; + standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); } } void SettingsDialog::chooseFixedFont() { - bool ok; - QFont font = QFontDialog::getFont(&ok, fixedFont, this); - if ( ok ) { - fixedFont = font; - fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(font.family()).arg(font.pointSize())); + + QFont myFont; + int result = KFontDialog::getFont( myFont , KFontChooser::FixedFontsOnly ); + if ( result == KFontDialog::Accepted ) + { + fixedFont = myFont; + fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); } } @@ -301,3 +302,14 @@ void SettingsDialog::setHomeToCurrentPage() homeLineEdit->setText(webView->url().toString()); } + +void SettingsDialog::slotOk() +{ + slotApply(); + close(); +} + +void SettingsDialog::slotApply() +{ + saveToSettings(); +} diff --git a/src/settings.h b/src/settings.h index fbedaf4e..9b452610 100644 --- a/src/settings.h +++ b/src/settings.h @@ -21,16 +21,21 @@ #ifndef SETTINGS_H #define SETTINGS_H -#include +// Local Includes #include "ui_settings.h" -class SettingsDialog : public QDialog, public Ui_Settings +// KDE Includes +#include + +// Qt Includes +#include + +class SettingsDialog : public KDialog, private Ui::Settings { Q_OBJECT public: SettingsDialog(QWidget *parent = 0); - void accept(); private slots: void loadDefaults(); @@ -44,9 +49,13 @@ private slots: void chooseFont(); void chooseFixedFont(); + void slotOk(); + void slotApply(); + private: QFont standardFont; QFont fixedFont; + QWidget *widget; }; #endif // SETTINGS_H diff --git a/src/settings.ui b/src/settings.ui index 3491ce0b..38c5ff13 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -1,42 +1,24 @@ Settings - + 0 0 - 657 - 322 + 570 + 248 - Settings + Form - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - + + 0 - - - 0 - 0 - 627 - 243 - - General @@ -52,7 +34,7 @@ - + @@ -129,7 +111,7 @@ - + @@ -171,14 +153,6 @@ - - - 0 - 0 - 627 - 243 - - Appearance @@ -265,14 +239,6 @@ - - - 0 - 0 - 627 - 243 - - Privacy @@ -311,7 +277,7 @@ Cookies - + @@ -403,14 +369,6 @@ - - - 0 - 0 - 627 - 243 - - Proxy @@ -459,7 +417,7 @@ - + @@ -505,7 +463,7 @@ - + @@ -518,10 +476,7 @@ - - - QLineEdit::Password - + @@ -542,73 +497,10 @@ - - - Advanced - - - - - - Style Sheet: - - - - - - - - - - Qt::Vertical - - - - 20 - 176 - - - - - - - - - buttonBox - accepted() - Settings - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Settings - reject() - - - 316 - 260 - - - 286 - 274 - - - - + -- cgit v1.2.1 From 3397fd277b12d82d8c260f8a9dab7b203924d1a8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 21 Nov 2008 09:48:44 +0100 Subject: KDE-izing cookie dialogs.. removed searchlineedit support, almost everywhere.. We just need a new url bar to be ready for 0.0.1 release.. --- src/CMakeLists.txt | 4 ++-- src/cookiejar.cpp | 25 ++++++++++++++++++++++++- src/cookiejar.h | 35 +++++++++++++++++++++++++++++------ src/cookies.ui | 7 +------ src/cookiesexceptions.ui | 9 ++------- src/history.ui | 7 +------ 6 files changed, 59 insertions(+), 28 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index edcfd561..b9d6a600 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,13 +9,13 @@ SET( rekonq_SRCS history.cpp modelmenu.cpp networkaccessmanager.cpp - searchlineedit.cpp + searchlineedit.cpp # ready to be removed.. findbar.cpp searchbar.cpp settings.cpp squeezelabel.cpp tabwidget.cpp - urllineedit.cpp + urllineedit.cpp # ready to be removed.. webview.cpp main.cpp ) diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index 8e985abc..9a6d8577 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -349,6 +349,12 @@ void CookieJar::setAllowForSessionCookies(const QStringList &list) m_saveTimer->changeOccurred(); } + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + + CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) : QAbstractTableModel(parent) , m_cookieJar(cookieJar) @@ -459,7 +465,14 @@ void CookieModel::cookiesChanged() reset(); } -CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) : QDialog(parent) + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + + +CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) + : QDialog(parent) { setupUi(this); setWindowFlags(Qt::Sheet); @@ -505,6 +518,10 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) : QDialog(pa +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + + CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent) : QAbstractTableModel(parent) , m_cookieJar(cookiejar) @@ -622,6 +639,12 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa return true; } + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + + CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent) : QDialog(parent) , m_cookieJar(cookieJar) diff --git a/src/cookiejar.h b/src/cookiejar.h index fbc89946..d3843c51 100644 --- a/src/cookiejar.h +++ b/src/cookiejar.h @@ -21,13 +21,16 @@ #ifndef COOKIEJAR_H #define COOKIEJAR_H -#include -#include -#include +// KDE Includes +#include -#include -#include + +// Qt Includes +#include +#include +#include +#include QT_BEGIN_NAMESPACE class QSortFilterProxyModel; @@ -105,6 +108,12 @@ private: QStringList m_exceptions_allowForSession; }; + + + // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + + class CookieModel : public QAbstractTableModel { Q_OBJECT @@ -124,8 +133,13 @@ private: CookieJar *m_cookieJar; }; + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + + #include "ui_cookies.h" -#include "ui_cookiesexceptions.h" class CookiesDialog : public QDialog, public Ui_CookiesDialog { @@ -160,6 +174,15 @@ private: QStringList m_sessionCookies; }; + + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + + +#include "ui_cookiesexceptions.h" + class CookiesExceptionsDialog : public QDialog, public Ui_CookiesExceptionsDialog { Q_OBJECT diff --git a/src/cookies.ui b/src/cookies.ui index c4bccc54..384b31b0 100644 --- a/src/cookies.ui +++ b/src/cookies.ui @@ -27,7 +27,7 @@ - + @@ -73,11 +73,6 @@ - - SearchLineEdit - QLineEdit -
searchlineedit.h
-
EditTableView QTableView diff --git a/src/cookiesexceptions.ui b/src/cookiesexceptions.ui index 3d9ef624..de59eee0 100644 --- a/src/cookiesexceptions.ui +++ b/src/cookiesexceptions.ui @@ -29,7 +29,7 @@
- + @@ -103,7 +103,7 @@ - + @@ -151,11 +151,6 @@ - - SearchLineEdit - QLineEdit -
searchlineedit.h
-
EditTableView QTableView diff --git a/src/history.ui b/src/history.ui index 0944940e..806bc9ad 100644 --- a/src/history.ui +++ b/src/history.ui @@ -27,7 +27,7 @@
- + @@ -73,11 +73,6 @@ - - SearchLineEdit - QLineEdit -
searchlineedit.h
-
EditTreeView QTreeView -- cgit v1.2.1 From aca0bf7ec9a98c1ef7a4147798c76e90e4cc7992 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 23 Nov 2008 00:09:49 +0100 Subject: 1st implementation of new (K)urlbar. It compiles but doesn't work (yet..) --- src/CMakeLists.txt | 5 ++- src/tabwidget.cpp | 24 ++++++----- src/tabwidget.h | 7 ++-- src/urlbar.cpp | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/urlbar.h | 36 +++++++++++++++++ 5 files changed, 171 insertions(+), 15 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b9d6a600..4498c543 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,13 +9,14 @@ SET( rekonq_SRCS history.cpp modelmenu.cpp networkaccessmanager.cpp - searchlineedit.cpp # ready to be removed.. + urlbar.cpp +# searchlineedit.cpp # ready to be removed.. findbar.cpp searchbar.cpp settings.cpp squeezelabel.cpp tabwidget.cpp - urllineedit.cpp # ready to be removed.. +# urllineedit.cpp # ready to be removed.. webview.cpp main.cpp ) diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 892c4cc5..d66b6ba3 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -25,7 +25,8 @@ #include "browserapplication.h" #include "browsermainwindow.h" #include "history.h" -#include "urllineedit.h" +// #include "urllineedit.h" +#include "urlbar.h" #include "webview.h" // Qt Includes @@ -286,7 +287,7 @@ void TabWidget::clear() m_recentlyClosedTabs.clear(); // clear the line edit history for (int i = 0; i < m_lineEdits->count(); ++i) { - QLineEdit *qLineEdit = lineEdit(i); + KLineEdit *qLineEdit = lineEdit(i); qLineEdit->setText(qLineEdit->text()); } } @@ -384,7 +385,7 @@ QWidget *TabWidget::lineEditStack() const return m_lineEdits; } -QLineEdit *TabWidget::currentLineEdit() const +KLineEdit *TabWidget::currentLineEdit() const { return lineEdit(m_lineEdits->currentIndex()); } @@ -394,9 +395,9 @@ WebView *TabWidget::currentWebView() const return webView(currentIndex()); } -QLineEdit *TabWidget::lineEdit(int index) const +KLineEdit *TabWidget::lineEdit(int index) const { - UrlLineEdit *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); + UrlBar *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); if (urlLineEdit) return urlLineEdit->lineEdit(); return 0; @@ -430,9 +431,10 @@ int TabWidget::webViewIndex(WebView *webView) const WebView *TabWidget::newTab(bool makeCurrent) { // line edit - UrlLineEdit *urlLineEdit = new UrlLineEdit; - QLineEdit *lineEdit = urlLineEdit->lineEdit(); - if (!m_lineEditCompleter && count() > 0) { + UrlBar *urlLineEdit = new UrlBar; + KLineEdit *lineEdit = urlLineEdit->lineEdit(); + if (!m_lineEditCompleter && count() > 0) + { HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel()); m_lineEditCompleter = new QCompleter(completionModel, this); @@ -448,7 +450,8 @@ WebView *TabWidget::newTab(bool makeCurrent) m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); // optimization to delay creating the more expensive WebView, history, etc - if (count() == 0) { + if (count() == 0) + { QWidget *emptyWidget = new QWidget; QPalette p = emptyWidget->palette(); p.setColor(QPalette::Window, palette().color(QPalette::Base)); @@ -515,7 +518,8 @@ void TabWidget::reloadAllTabs() void TabWidget::lineEditReturnPressed() { - if (QLineEdit *lineEdit = qobject_cast(sender())) { + if (KLineEdit *lineEdit = qobject_cast(sender())) + { emit loadPage(lineEdit->text()); if (m_lineEdits->currentWidget() == lineEdit) currentWebView()->setFocus(); diff --git a/src/tabwidget.h b/src/tabwidget.h index b3c31c0e..e6399971 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -109,9 +109,10 @@ private: #include #include +#include + QT_BEGIN_NAMESPACE class QCompleter; -class QLineEdit; class QMenu; class QStackedWidget; QT_END_NAMESPACE @@ -154,10 +155,10 @@ public: QAction *previousTabAction() const; QWidget *lineEditStack() const; - QLineEdit *currentLineEdit() const; + KLineEdit *currentLineEdit() const; WebView *currentWebView() const; WebView *webView(int index) const; - QLineEdit *lineEdit(int index) const; + KLineEdit *lineEdit(int index) const; int webViewIndex(WebView *webView) const; QByteArray saveState() const; diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 62b28614..e7ce461a 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -17,9 +17,123 @@  *  * ============================================================ */ +// Local Includes +#include "urlbar.h" +#include "urlbar.moc" +#include "browserapplication.h" +// Qt Includes +#include +#include +#include +#include +#include +#include +UrlBar::UrlBar(QWidget *parent) + : QWidget(parent) + , m_webView(0) + , m_iconLabel(0) + , m_lineEdit(0) +{ + // icon + m_iconLabel = new QLabel; + m_iconLabel->resize(16, 16); + + m_lineEdit = new KLineEdit; + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(m_iconLabel); + layout->addWidget(m_lineEdit); + setLayout(layout); + + m_defaultBaseColor = palette().color(QPalette::Base); + + webViewIconChanged(); +} + +UrlBar::~UrlBar() +{ +// delete m_webView; + delete m_iconLabel; + delete m_lineEdit; +} + +KLineEdit *UrlBar::lineEdit() +{ + return m_lineEdit; +} + +void UrlBar::setWebView(WebView *webView) +{ + Q_ASSERT(!m_webView); + m_webView = webView; +// m_iconLabel->m_webView = webView; + connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); + connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(loadProgress(int)), this, SLOT(update())); +} + +void UrlBar::paintEvent(QPaintEvent *event) +{ + QPainter p(this); + QStyleOptionFrameV2 *optionPanel; + + optionPanel->initFrom(this); + optionPanel->rect = contentsRect(); + optionPanel->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, optionPanel, this); + optionPanel->midLineWidth = 0; + optionPanel->state |= QStyle::State_Sunken; + if (m_lineEdit->isReadOnly()) + optionPanel->state |= QStyle::State_ReadOnly; + optionPanel->features = QStyleOptionFrameV2::None; + + style()->drawPrimitive(QStyle::PE_PanelLineEdit, optionPanel, &p, (QWidget *) this); +} + +void UrlBar::focusOutEvent(QFocusEvent *event) +{ + if (m_lineEdit->text().isEmpty() && m_webView) + { + m_lineEdit->setText(m_webView->url().toString()); + } + +// m_lineEdit->event(event); // FIXME + + if (m_lineEdit->completer()) + { + connect(m_lineEdit->completer(), SIGNAL(activated(QString)), m_lineEdit, SLOT(setText(QString))); + connect(m_lineEdit->completer(), SIGNAL(highlighted(QString)), m_lineEdit, SLOT(_q_completionHighlighted(QString))); + } + QWidget::focusOutEvent(event); +} + +void UrlBar::webViewUrlChanged(const QUrl &url) +{ + m_lineEdit->setText(url.toString()); + m_lineEdit->setCursorPosition(0); +} + +void UrlBar::webViewIconChanged() +{ + QUrl url = (m_webView) ? m_webView->url() : QUrl(); + QIcon icon = BrowserApplication::instance()->icon(url); + QPixmap pixmap(icon.pixmap(16, 16)); + m_iconLabel->setPixmap(pixmap); +} + +QLinearGradient UrlBar::generateGradient(const QColor &color) const +{ + QLinearGradient gradient(0, 0, 0, height()); + gradient.setColorAt(0, m_defaultBaseColor); + gradient.setColorAt(0.15, color.lighter(120)); + gradient.setColorAt(0.5, color); + gradient.setColorAt(0.85, color.lighter(120)); + gradient.setColorAt(1, m_defaultBaseColor); + return gradient; +} diff --git a/src/urlbar.h b/src/urlbar.h index 13c4c320..db6304da 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -20,9 +20,45 @@ #ifndef URLBAR_H #define URLBAR_H +// Local Includes +#include "webview.h" +// KDE Includes +#include +// Qt Includes +#include +#include +class UrlBar : public QWidget +{ +Q_OBJECT + +public: + UrlBar(QWidget *parent = 0); + ~UrlBar(); + + KLineEdit *lineEdit(); + + void setWebView(WebView *webView); + +protected: + void paintEvent(QPaintEvent *event); + void focusOutEvent(QFocusEvent *event); + +private slots: + void webViewUrlChanged(const QUrl &url); + void webViewIconChanged(); + +private: + QLinearGradient generateGradient(const QColor &color) const; + + WebView *m_webView; + + QLabel *m_iconLabel; + KLineEdit *m_lineEdit; + QColor m_defaultBaseColor; +}; #endif -- cgit v1.2.1 From d4ee1b6a519d342109cd2cda52d30ea776065e11 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 27 Nov 2008 16:45:38 +0100 Subject: New step forwad in the street from QAction to KAction.. --- .gitignore | 2 + src/browsermainwindow.cpp | 11 +-- src/browsermainwindow.h | 4 +- src/tabwidget.cpp | 185 ++++++++++++++++++++++++---------------------- src/tabwidget.h | 35 +++++---- src/urlbar.cpp | 18 ++--- 6 files changed, 133 insertions(+), 122 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..51b75647 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +qtdemobrowser + diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 4ea1d444..64f9c56f 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -225,6 +225,7 @@ void BrowserMainWindow::setupMenu() fileMenu->addAction( i18n("Open Location"), this, SLOT( slotSelectLineEdit() ) ); fileMenu->addSeparator(); + fileMenu->addAction( m_tabWidget->newTabAction() ); fileMenu->addAction( m_tabWidget->closeTabAction() ); fileMenu->addSeparator(); @@ -239,7 +240,7 @@ void BrowserMainWindow::setupMenu() action->setCheckable(true); fileMenu->addSeparator(); - fileMenu->addAction( KStandardAction::close( this , SLOT( close() ), this ) ); + fileMenu->addAction( KStandardAction::quit( this , SLOT( close() ), this ) ); // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- KMenu *editMenu = (KMenu *) menuBar()->addMenu( i18n("&Edit") ); @@ -313,14 +314,14 @@ void BrowserMainWindow::setupMenu() menuBar()->addMenu(historyMenu); QList historyActions; - m_historyBack = new QAction( i18n("Back"), this); + m_historyBack = new KAction( i18n("Back"), this); m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); - m_historyBack->setShortcuts(QKeySequence::Back); +// m_historyBack->setShortcuts(QKeySequence::Back); FIXME m_historyBack->setIconVisibleInMenu(false); - m_historyForward = new QAction( i18n("Forward"), this); + m_historyForward = new KAction( i18n("Forward"), this); m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); - m_historyForward->setShortcuts(QKeySequence::Forward); +// m_historyForward->setShortcuts(QKeySequence::Forward); FIXME m_historyForward->setIconVisibleInMenu(false); m_restoreLastSession = new QAction( i18n("Restore Last Session"), this); diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index c5db7bba..fc57c6b9 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -132,9 +132,9 @@ private: TabWidget *m_tabWidget; AutoSaver *m_autoSaver; - QAction *m_historyBack; + KAction *m_historyBack; KMenu *m_historyBackMenu; - QAction *m_historyForward; + KAction *m_historyForward; KMenu *m_windowMenu; KAction *m_stop; diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index d66b6ba3..e54dbee5 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -179,18 +179,6 @@ void TabBar::dropEvent(QDropEvent *event) QTabBar::dropEvent(event); } -// When index is -1 index chooses the current tab -void TabWidget::reloadTab(int index) -{ - if (index < 0) - index = currentIndex(); - if (index < 0 || index >= count()) - return; - - QWidget *widget = this->widget(index); - if (WebView *tab = qobject_cast(widget)) - tab->reload(); -} void TabBar::reloadTab() { @@ -226,17 +214,17 @@ TabWidget::TabWidget(QWidget *parent) setTabBar(m_tabBar); // Actions - m_newTabAction = new QAction(KIcon("tab-new"), i18n("New &Tab"), this); - m_newTabAction->setShortcuts(QKeySequence::AddTab); + m_newTabAction = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); +// m_newTabAction->setShortcuts(QKeySequence::AddTab); FIXME m_newTabAction->setIconVisibleInMenu(false); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); - m_closeTabAction = new QAction(KIcon("tab-close"), i18n("&Close Tab"), this); - m_closeTabAction->setShortcuts(QKeySequence::Close); + m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); +// m_closeTabAction->setShortcuts(QKeySequence::Close); FIXME m_closeTabAction->setIconVisibleInMenu(false); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); - m_nextTabAction = new QAction(i18n("Show Next Tab"), this); + m_nextTabAction = new KAction(i18n("Show Next Tab"), this); QList shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); @@ -245,7 +233,7 @@ TabWidget::TabWidget(QWidget *parent) m_nextTabAction->setShortcuts(shortcuts); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); - m_previousTabAction = new QAction(i18n("Show Previous Tab"), this); + m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); shortcuts.clear(); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); @@ -255,11 +243,9 @@ TabWidget::TabWidget(QWidget *parent) connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); m_recentlyClosedTabsMenu = new QMenu(this); - connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), - this, SLOT(aboutToShowRecentTabsMenu())); - connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), - this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); - m_recentlyClosedTabsAction = new QAction(i18n("Recently Closed Tabs"), this); + connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); + connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); + m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); @@ -304,12 +290,25 @@ void TabWidget::moveTab(int fromIndex, int toIndex) removeTab(fromIndex); insertTab(toIndex, tabWidget, icon, text); m_tabBar->setTabData(toIndex, data); - connect(this, SIGNAL(currentChanged(int)), - this, SLOT(currentChanged(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); setCurrentIndex(toIndex); } -void TabWidget::addWebAction(QAction *action, QWebPage::WebAction webAction) +// When index is -1 index chooses the current tab +void TabWidget::reloadTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + QWidget *widget = this->widget(index); + if (WebView *tab = qobject_cast(widget)) + tab->reload(); +} + + +void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction) { if (!action) return; @@ -325,7 +324,8 @@ void TabWidget::currentChanged(int index) Q_ASSERT(m_lineEdits->count() == count()); WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); - if (oldWebView) { + if (oldWebView) + { disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), @@ -341,7 +341,8 @@ void TabWidget::currentChanged(int index) connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); - for (int i = 0; i < m_actions.count(); ++i) { + for (int i = 0; i < m_actions.count(); ++i) + { WebActionMapper *mapper = m_actions[i]; mapper->updateCurrent(webView->page()); } @@ -355,27 +356,27 @@ void TabWidget::currentChanged(int index) webView->setFocus(); } -QAction *TabWidget::newTabAction() const +KAction *TabWidget::newTabAction() const { return m_newTabAction; } -QAction *TabWidget::closeTabAction() const +KAction *TabWidget::closeTabAction() const { return m_closeTabAction; } -QAction *TabWidget::recentlyClosedTabsAction() const +KAction *TabWidget::recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; } -QAction *TabWidget::nextTabAction() const +KAction *TabWidget::nextTabAction() const { return m_nextTabAction; } -QAction *TabWidget::previousTabAction() const +KAction *TabWidget::previousTabAction() const { return m_previousTabAction; } @@ -406,11 +407,15 @@ KLineEdit *TabWidget::lineEdit(int index) const WebView *TabWidget::webView(int index) const { QWidget *widget = this->widget(index); - if (WebView *webView = qobject_cast(widget)) { + if (WebView *webView = qobject_cast(widget)) + { return webView; - } else { + } + else + { // optimization to delay creating the first webview - if (count() == 1) { + if (count() == 1) + { TabWidget *that = const_cast(this); that->setUpdatesEnabled(false); that->newTab(); @@ -457,47 +462,36 @@ WebView *TabWidget::newTab(bool makeCurrent) p.setColor(QPalette::Window, palette().color(QPalette::Base)); emptyWidget->setPalette(p); emptyWidget->setAutoFillBackground(true); - disconnect(this, SIGNAL(currentChanged(int)), - this, SLOT(currentChanged(int))); + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); addTab(emptyWidget, i18n("(Untitled)")); - connect(this, SIGNAL(currentChanged(int)), - this, SLOT(currentChanged(int))); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); return 0; } // webview WebView *webView = new WebView; urlLineEdit->setWebView(webView); - connect(webView, SIGNAL(loadStarted()), - this, SLOT(webViewLoadStarted())); - connect(webView, SIGNAL(loadFinished(bool)), - this, SLOT(webViewIconChanged())); - connect(webView, SIGNAL(iconChanged()), - this, SLOT(webViewIconChanged())); - connect(webView, SIGNAL(titleChanged(const QString &)), - this, SLOT(webViewTitleChanged(const QString &))); - connect(webView, SIGNAL(urlChanged(const QUrl &)), - this, SLOT(webViewUrlChanged(const QUrl &))); - connect(webView->page(), SIGNAL(windowCloseRequested()), - this, SLOT(windowCloseRequested())); - connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), - this, SIGNAL(geometryChangeRequested(const QRect &))); - connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), - this, SIGNAL(printRequested(QWebFrame *))); - connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), - this, SIGNAL(menuBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), - this, SIGNAL(statusBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), - this, SIGNAL(toolBarVisibilityChangeRequested(bool))); + + connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); + connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); + connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); + connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); + connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), this, SIGNAL(geometryChangeRequested(const QRect &))); + connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); + connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); addTab(webView, i18n("(Untitled)")); if (makeCurrent) setCurrentWidget(webView); // webview actions - for (int i = 0; i < m_actions.count(); ++i) { + for (int i = 0; i < m_actions.count(); ++i) + { WebActionMapper *mapper = m_actions[i]; - mapper->addChild(webView->page()->action(mapper->webAction())); + mapper->addChild( new KAction( webView->page()->action( mapper->webAction() ) ) ); } if (count() == 1) @@ -508,9 +502,11 @@ WebView *TabWidget::newTab(bool makeCurrent) void TabWidget::reloadAllTabs() { - for (int i = 0; i < count(); ++i) { + for (int i = 0; i < count(); ++i) + { QWidget *tabWidget = widget(i); - if (WebView *tab = qobject_cast(tabWidget)) { + if (WebView *tab = qobject_cast(tabWidget)) + { tab->reload(); } } @@ -531,7 +527,8 @@ void TabWidget::windowCloseRequested() WebPage *webPage = qobject_cast(sender()); WebView *webView = qobject_cast(webPage->view()); int index = webViewIndex(webView); - if (index >= 0) { + if (index >= 0) + { if (count() == 1) webView->webPage()->mainWindow()->close(); else @@ -608,7 +605,7 @@ void TabWidget::webViewLoadStarted() WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); if (-1 != index) { - QIcon icon(QLatin1String(":loading.gif")); + QIcon icon(QLatin1String(":loading.gif")); // FIXME setTabIcon(index, icon); } } @@ -617,7 +614,8 @@ void TabWidget::webViewIconChanged() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { + if (-1 != index) + { QIcon icon = BrowserApplication::instance()->icon(webView->url()); setTabIcon(index, icon); } @@ -648,8 +646,9 @@ void TabWidget::webViewUrlChanged(const QUrl &url) void TabWidget::aboutToShowRecentTabsMenu() { m_recentlyClosedTabsMenu->clear(); - for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) { - QAction *action = new QAction(m_recentlyClosedTabsMenu); + for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) + { + KAction *action = new KAction(m_recentlyClosedTabsMenu); action->setData(m_recentlyClosedTabs.at(i)); QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); action->setIcon(icon); @@ -658,7 +657,7 @@ void TabWidget::aboutToShowRecentTabsMenu() } } -void TabWidget::aboutToShowRecentTriggeredAction(QAction *action) +void TabWidget::aboutToShowRecentTriggeredAction(KAction *action) { QUrl url = action->data().toUrl(); loadUrlInCurrentTab(url); @@ -688,9 +687,11 @@ void TabWidget::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::MidButton && !childAt(event->pos()) // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) { + && event->pos().y() < (tabBar()->y() + tabBar()->height())) + { QUrl url(QApplication::clipboard()->text(QClipboard::Selection)); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + { WebView *webView = newTab(); webView->setUrl(url); } @@ -700,7 +701,8 @@ void TabWidget::mouseReleaseEvent(QMouseEvent *event) void TabWidget::loadUrlInCurrentTab(const QUrl &url) { WebView *webView = currentWebView(); - if (webView) { + if (webView) + { webView->loadUrl(url); webView->setFocus(); } @@ -734,10 +736,14 @@ QByteArray TabWidget::saveState() const stream << qint32(version); QStringList tabs; - for (int i = 0; i < count(); ++i) { - if (WebView *tab = qobject_cast(widget(i))) { + for (int i = 0; i < count(); ++i) + { + if (WebView *tab = qobject_cast(widget(i))) + { tabs.append(tab->url().toString()); - } else { + } + else + { tabs.append(QString::null); } } @@ -764,7 +770,8 @@ bool TabWidget::restoreState(const QByteArray &state) QStringList openTabs; stream >> openTabs; - for (int i = 0; i < openTabs.count(); ++i) { + for (int i = 0; i < openTabs.count(); ++i) + { if (i != 0) newTab(); loadPage(openTabs.at(i)); @@ -777,7 +784,7 @@ bool TabWidget::restoreState(const QByteArray &state) return true; } -WebActionMapper::WebActionMapper(QAction *root, QWebPage::WebAction webAction, QObject *parent) +WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) : QObject(parent) , m_currentParent(0) , m_root(root) @@ -800,7 +807,7 @@ void WebActionMapper::currentDestroyed() updateCurrent(0); } -void WebActionMapper::addChild(QAction *action) +void WebActionMapper::addChild(KAction *action) { if (!action) return; @@ -814,18 +821,21 @@ QWebPage::WebAction WebActionMapper::webAction() const void WebActionMapper::rootTriggered() { - if (m_currentParent) { - QAction *gotoAction = m_currentParent->action(m_webAction); + if (m_currentParent) + { + KAction *gotoAction = new KAction( m_currentParent->action(m_webAction) ); gotoAction->trigger(); } } void WebActionMapper::childChanged() { - if (QAction *source = qobject_cast(sender())) { + if (KAction *source = qobject_cast(sender())) + { if (m_root && m_currentParent - && source->parent() == m_currentParent) { + && source->parent() == m_currentParent) + { m_root->setChecked(source->isChecked()); m_root->setEnabled(source->isEnabled()); } @@ -846,9 +856,8 @@ void WebActionMapper::updateCurrent(QWebPage *currentParent) m_root->setChecked(false); return; } - QAction *source = m_currentParent->action(m_webAction); + KAction *source = new KAction( m_currentParent->action(m_webAction) ); m_root->setChecked(source->isChecked()); m_root->setEnabled(source->isEnabled()); - connect(m_currentParent, SIGNAL(destroyed(QObject *)), - this, SLOT(currentDestroyed())); + connect(m_currentParent, SIGNAL(destroyed(QObject *)), this, SLOT(currentDestroyed())); } diff --git a/src/tabwidget.h b/src/tabwidget.h index e6399971..7323c59d 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -24,6 +24,8 @@ #define TABWIDGET_H #include +#include + #include /* Tab bar with a few more features such as a context menu and shortcuts @@ -70,9 +72,6 @@ private: #include -QT_BEGIN_NAMESPACE -class QAction; -QT_END_NAMESPACE class WebView; /*! A proxy object that connects a single browser action @@ -86,9 +85,9 @@ class WebActionMapper : public QObject Q_OBJECT public: - WebActionMapper(QAction *root, QWebPage::WebAction webAction, QObject *parent); + WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent); QWebPage::WebAction webAction() const; - void addChild(QAction *action); + void addChild(KAction *action); void updateCurrent(QWebPage *currentParent); private slots: @@ -99,7 +98,7 @@ private slots: private: QWebPage *m_currentParent; - QAction *m_root; + KAction *m_root; QWebPage::WebAction m_webAction; }; @@ -146,13 +145,13 @@ signals: public: TabWidget(QWidget *parent = 0); void clear(); - void addWebAction(QAction *action, QWebPage::WebAction webAction); + void addWebAction(KAction *action, QWebPage::WebAction webAction); - QAction *newTabAction() const; - QAction *closeTabAction() const; - QAction *recentlyClosedTabsAction() const; - QAction *nextTabAction() const; - QAction *previousTabAction() const; + KAction *newTabAction() const; + KAction *closeTabAction() const; + KAction *recentlyClosedTabsAction() const; + KAction *nextTabAction() const; + KAction *previousTabAction() const; QWidget *lineEditStack() const; KLineEdit *currentLineEdit() const; @@ -183,7 +182,7 @@ public slots: private slots: void currentChanged(int index); void aboutToShowRecentTabsMenu(); - void aboutToShowRecentTriggeredAction(QAction *action); + void aboutToShowRecentTriggeredAction(KAction *action); void webViewLoadStarted(); void webViewIconChanged(); void webViewTitleChanged(const QString &title); @@ -193,11 +192,11 @@ private slots: void moveTab(int fromIndex, int toIndex); private: - QAction *m_recentlyClosedTabsAction; - QAction *m_newTabAction; - QAction *m_closeTabAction; - QAction *m_nextTabAction; - QAction *m_previousTabAction; + KAction *m_recentlyClosedTabsAction; + KAction *m_newTabAction; + KAction *m_closeTabAction; + KAction *m_nextTabAction; + KAction *m_previousTabAction; QMenu *m_recentlyClosedTabsMenu; static const int m_recentlyClosedTabsSize = 10; diff --git a/src/urlbar.cpp b/src/urlbar.cpp index e7ce461a..16783313 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -81,18 +81,18 @@ void UrlBar::setWebView(WebView *webView) void UrlBar::paintEvent(QPaintEvent *event) { QPainter p(this); - QStyleOptionFrameV2 *optionPanel; + QStyleOptionFrameV2 optionPanel; - optionPanel->initFrom(this); - optionPanel->rect = contentsRect(); - optionPanel->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, optionPanel, this); - optionPanel->midLineWidth = 0; - optionPanel->state |= QStyle::State_Sunken; + optionPanel.initFrom(this); + optionPanel.rect = contentsRect(); + optionPanel.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &optionPanel, this); + optionPanel.midLineWidth = 0; + optionPanel.state |= QStyle::State_Sunken; if (m_lineEdit->isReadOnly()) - optionPanel->state |= QStyle::State_ReadOnly; - optionPanel->features = QStyleOptionFrameV2::None; + optionPanel.state |= QStyle::State_ReadOnly; + optionPanel.features = QStyleOptionFrameV2::None; - style()->drawPrimitive(QStyle::PE_PanelLineEdit, optionPanel, &p, (QWidget *) this); + style()->drawPrimitive(QStyle::PE_PanelLineEdit, &optionPanel, &p, (QWidget *) this); } void UrlBar::focusOutEvent(QFocusEvent *event) -- cgit v1.2.1 From 5b5bbe370303f6d146c125b0cb0b0c465cc1b3ff Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 28 Nov 2008 02:05:42 +0100 Subject: Final (hopefully) adjustments in tabwidget (Q/K)action management.. --- src/tabwidget.cpp | 15 ++++++++------- src/tabwidget.h | 5 +++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index e54dbee5..ef3dc4ea 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -215,12 +215,12 @@ TabWidget::TabWidget(QWidget *parent) // Actions m_newTabAction = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); -// m_newTabAction->setShortcuts(QKeySequence::AddTab); FIXME + m_newTabAction->setShortcuts(KShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_N, Qt::CTRL+Qt::Key_T)); m_newTabAction->setIconVisibleInMenu(false); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); -// m_closeTabAction->setShortcuts(QKeySequence::Close); FIXME + m_closeTabAction->setShortcut(Qt::CTRL+Qt::Key_W); m_closeTabAction->setIconVisibleInMenu(false); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); @@ -242,7 +242,7 @@ TabWidget::TabWidget(QWidget *parent) m_previousTabAction->setShortcuts(shortcuts); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); - m_recentlyClosedTabsMenu = new QMenu(this); + m_recentlyClosedTabsMenu = new KMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); @@ -657,7 +657,7 @@ void TabWidget::aboutToShowRecentTabsMenu() } } -void TabWidget::aboutToShowRecentTriggeredAction(KAction *action) +void TabWidget::aboutToShowRecentTriggeredAction(QAction *action) { QUrl url = action->data().toUrl(); loadUrlInCurrentTab(url); @@ -665,9 +665,10 @@ void TabWidget::aboutToShowRecentTriggeredAction(KAction *action) void TabWidget::mouseDoubleClickEvent(QMouseEvent *event) { - if (!childAt(event->pos()) - // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) { + if ( !childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) + { newTab(); return; } diff --git a/src/tabwidget.h b/src/tabwidget.h index 7323c59d..63cd4e48 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -109,6 +109,7 @@ private: #include #include +#include QT_BEGIN_NAMESPACE class QCompleter; @@ -182,7 +183,7 @@ public slots: private slots: void currentChanged(int index); void aboutToShowRecentTabsMenu(); - void aboutToShowRecentTriggeredAction(KAction *action); + void aboutToShowRecentTriggeredAction(QAction *action); // need QAction! void webViewLoadStarted(); void webViewIconChanged(); void webViewTitleChanged(const QString &title); @@ -198,7 +199,7 @@ private: KAction *m_nextTabAction; KAction *m_previousTabAction; - QMenu *m_recentlyClosedTabsMenu; + KMenu *m_recentlyClosedTabsMenu; static const int m_recentlyClosedTabsSize = 10; QList m_recentlyClosedTabs; QList m_actions; -- cgit v1.2.1 From 5e88992daa37f0906fa2c370ef1aaaf9d04e869a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 28 Nov 2008 10:34:54 +0100 Subject: Other QAction -> KAction --- src/browsermainwindow.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 64f9c56f..528beb13 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -89,18 +89,18 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) centralWidget->setLayout(layout); setCentralWidget(centralWidget); - connect(m_tabWidget, SIGNAL(loadPage(const QString &)), this, SLOT(loadPage(const QString &))); - connect(m_tabWidget, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); - connect(m_tabWidget, SIGNAL(showStatusBarMessage(const QString&)), statusBar(), SLOT(showMessage(const QString&))); - connect(m_tabWidget, SIGNAL(linkHovered(const QString&)), statusBar(), SLOT(showMessage(const QString&))); - connect(m_tabWidget, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); - connect(m_tabWidget, SIGNAL(tabsChanged()), m_autoSaver, SLOT(changeOccurred())); - connect(m_tabWidget, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &))); - connect(m_tabWidget, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); - connect(m_tabWidget, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); - connect(m_tabWidget, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); - connect(m_tabWidget, SIGNAL(toolBarVisibilityChangeRequested(bool)), m_navigationBar, SLOT(setVisible(bool))); - connect(m_tabWidget, SIGNAL(lastTabClosed()), m_tabWidget, SLOT(newTab())); + connect(m_tabWidget, SIGNAL( loadPage(const QString &) ), this, SLOT( loadPage(const QString &) ) ); + connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); + connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); + connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); + connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); + connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); + connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); + connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); + connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); + connect(m_tabWidget, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); + connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) ); + connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); slotUpdateWindowTitle(); loadDefaultState(); @@ -236,7 +236,7 @@ void BrowserMainWindow::setupMenu() fileMenu->addAction( KStandardAction::print( this, SLOT(slotFilePrint()), this) ); fileMenu->addSeparator(); - QAction *action = fileMenu->addAction( i18n("Private &Browsing..."), this, SLOT( slotPrivateBrowsing() ) ); + KAction *action = (KAction *) fileMenu->addAction( i18n("Private &Browsing..."), this, SLOT( slotPrivateBrowsing() ) ); action->setCheckable(true); fileMenu->addSeparator(); @@ -303,7 +303,7 @@ void BrowserMainWindow::setupMenu() viewMenu->addSeparator(); viewMenu->addAction( i18n("Page S&ource"), this, SLOT(slotViewPageSource()), i18n("Ctrl+Alt+U")); - action = viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); + action = (KAction *) viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); action->setCheckable(true); // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- @@ -358,7 +358,7 @@ void BrowserMainWindow::setupMenu() KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); - action = toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); + action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); action->setCheckable(true); -- cgit v1.2.1 From ec154e126f4ae0febbbb7fef298ca6d98aee836d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 28 Nov 2008 10:35:19 +0100 Subject: New findbar implementation. Now it will be shown with CTRL+F, but NOT hidden with ESC button. Also doesn't search --- src/findbar.cpp | 48 ++++++++++++++++-------------------------------- src/findbar.h | 8 ++++---- 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/src/findbar.cpp b/src/findbar.cpp index ae64b7f6..45de4246 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -26,57 +26,48 @@ #include #include -#include -#include -#include -#include -#include -#include +#include FindBar::FindBar(QWidget *parent) - : QWidget(parent) + : KToolBar(parent) , m_lineEdit(0) { initializeFindWidget(); // we start off hidden - setMaximumHeight(0); -// m_widget->setGeometry(0, -1 * m_widget->height(), m_widget->width(), m_widget->height()); hide(); - - new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(hide())); } + FindBar::~FindBar() { delete m_lineEdit; } -void FindBar::initializeFindWidget() +KLineEdit *FindBar::lineEdit() { - QHBoxLayout *layout = new QHBoxLayout(); + return m_lineEdit; +} - KToolBar *bar1 = new KToolBar(this); - bar1->addAction( KStandardAction::close(this, SLOT( hide() ) , this ) ); - layout->addWidget( bar1 ); + +void FindBar::initializeFindWidget() +{ + addAction( KIcon("dialog-close") , "close" , this, SLOT( hide() ) ); QLabel *label = new QLabel("Find: "); - layout->addWidget( label ); + addWidget( label ); m_lineEdit = new KLineEdit(); connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); - layout->addWidget( m_lineEdit ); - - KToolBar *bar2 = new KToolBar(this); - bar2->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - bar2->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); - layout->addWidget( bar2 ); + addWidget( m_lineEdit ); - layout->addStretch(); + addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); + addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); - setLayout(layout); + QLabel *spaceLabel = new QLabel(" "); // FIXME + addWidget( spaceLabel ); } @@ -98,13 +89,6 @@ void FindBar::showFind() } -void FindBar::resizeEvent(QResizeEvent *event) -{ -/* if (event->size().width() != m_widget->width()) - m_widget->resize(event->size().width(), m_widget->height()); - QWidget::resizeEvent(event);*/ -} - void FindBar::frameChanged(int frame) { diff --git a/src/findbar.h b/src/findbar.h index 214a06e2..05dbf820 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -21,16 +21,18 @@ #define FINDBAR_H #include +#include #include -class FindBar : public QWidget +class FindBar : public KToolBar { Q_OBJECT public: FindBar(QWidget *parent = 0); ~FindBar(); + KLineEdit *lineEdit(); public slots: void clear(); @@ -38,9 +40,6 @@ public slots: void slotFindNext(); void slotFindPrevious(); -protected: - void resizeEvent(QResizeEvent *event); - private slots: void frameChanged(int frame); @@ -48,6 +47,7 @@ private: void initializeFindWidget(); KLineEdit *m_lineEdit; + QWidget *m_centralWidget; }; #endif -- cgit v1.2.1 From e9bfe8629fcb5cb964d0f60edc1473783f98a72e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 28 Nov 2008 10:57:06 +0100 Subject: Definitely removed searclineedit and urllineedit classes. Will use my own.. ;) --- src/CMakeLists.txt | 2 - src/searchlineedit.cpp | 219 ----------------------------------- src/searchlineedit.h | 84 -------------- src/urllineedit.cpp | 308 ------------------------------------------------- src/urllineedit.h | 93 --------------- 5 files changed, 706 deletions(-) delete mode 100644 src/searchlineedit.cpp delete mode 100644 src/searchlineedit.h delete mode 100644 src/urllineedit.cpp delete mode 100644 src/urllineedit.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4498c543..bb01a78e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,13 +10,11 @@ SET( rekonq_SRCS modelmenu.cpp networkaccessmanager.cpp urlbar.cpp -# searchlineedit.cpp # ready to be removed.. findbar.cpp searchbar.cpp settings.cpp squeezelabel.cpp tabwidget.cpp -# urllineedit.cpp # ready to be removed.. webview.cpp main.cpp ) diff --git a/src/searchlineedit.cpp b/src/searchlineedit.cpp deleted file mode 100644 index 620b3991..00000000 --- a/src/searchlineedit.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -// Local Includes -#include "searchlineedit.h" - -// Qt Includes -#include -#include -#include -#include -#include - - -ClearButton::ClearButton(QWidget *parent) - : QAbstractButton(parent) -{ - setCursor(Qt::ArrowCursor); - setToolTip( tr("Clear") ); - setVisible(false); - setFocusPolicy(Qt::NoFocus); -} - -void ClearButton::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainter painter(this); - int height = this->height(); - - painter.setRenderHint(QPainter::Antialiasing, true); - QColor color = palette().color(QPalette::Mid); - painter.setBrush(isDown() - ? palette().color(QPalette::Dark) - : palette().color(QPalette::Mid)); - painter.setPen(painter.brush().color()); - int size = width(); - int offset = size / 5; - int radius = size - offset * 2; - painter.drawEllipse(offset, offset, radius, radius); - - painter.setPen(palette().color(QPalette::Base)); - int border = offset * 2; - painter.drawLine(border, border, width() - border, height - border); - painter.drawLine(border, height - border, width() - border, border); -} - -void ClearButton::textChanged(const QString &text) -{ - setVisible(!text.isEmpty()); -} - -/* - Search icon on the left hand side of the search widget - When a menu is set a down arrow appears - */ -class SearchButton : public QAbstractButton { -public: - SearchButton(QWidget *parent = 0); - void paintEvent(QPaintEvent *event); - QMenu *m_menu; - -protected: - void mousePressEvent(QMouseEvent *event); -}; - -SearchButton::SearchButton(QWidget *parent) - : QAbstractButton(parent), - m_menu(0) -{ - setObjectName(QLatin1String("SearchButton")); - setCursor(Qt::ArrowCursor); - setFocusPolicy(Qt::NoFocus); -} - -void SearchButton::mousePressEvent(QMouseEvent *event) -{ - if (m_menu && event->button() == Qt::LeftButton) { - QWidget *p = parentWidget(); - if (p) { - QPoint r = p->mapToGlobal(QPoint(0, p->height())); - m_menu->exec(QPoint(r.x() + height() / 2, r.y())); - } - event->accept(); - } - QAbstractButton::mousePressEvent(event); -} - -void SearchButton::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - QPainterPath myPath; - - int radius = (height() / 5) * 2; - QRect circle(height() / 3 - 1, height() / 4, radius, radius); - myPath.addEllipse(circle); - - myPath.arcMoveTo(circle, 300); - QPointF c = myPath.currentPosition(); - int diff = height() / 7; - myPath.lineTo(qMin(width() - 2, (int)c.x() + diff), c.y() + diff); - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setPen(QPen(Qt::darkGray, 2)); - painter.drawPath(myPath); - - if (m_menu) { - QPainterPath dropPath; - dropPath.arcMoveTo(circle, 320); - QPointF c = dropPath.currentPosition(); - c = QPointF(c.x() + 3.5, c.y() + 0.5); - dropPath.moveTo(c); - dropPath.lineTo(c.x() + 4, c.y()); - dropPath.lineTo(c.x() + 2, c.y() + 2); - dropPath.closeSubpath(); - painter.setPen(Qt::darkGray); - painter.setBrush(Qt::darkGray); - painter.setRenderHint(QPainter::Antialiasing, false); - painter.drawPath(dropPath); - } - painter.end(); -} - -/* - SearchLineEdit is an enhanced QLineEdit - - A Search icon on the left with optional menu - - When there is no text and doesn't have focus an "inactive text" is displayed - - When there is text a clear button is displayed on the right hand side - */ -SearchLineEdit::SearchLineEdit(QWidget *parent) : ExLineEdit(parent), - m_searchButton(new SearchButton(this)) -{ - connect(lineEdit(), SIGNAL(textChanged(const QString &)), - this, SIGNAL(textChanged(const QString &))); - setLeftWidget(m_searchButton); - m_inactiveText = tr("Search"); - - QSizePolicy policy = sizePolicy(); - setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); -} - -void SearchLineEdit::paintEvent(QPaintEvent *event) -{ - if (lineEdit()->text().isEmpty() && !hasFocus() && !m_inactiveText.isEmpty()) { - ExLineEdit::paintEvent(event); - QStyleOptionFrameV2 panel; - initStyleOption(&panel); - QRect r = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); - QFontMetrics fm = fontMetrics(); - int horizontalMargin = lineEdit()->x(); - QRect lineRect(horizontalMargin + r.x(), r.y() + (r.height() - fm.height() + 1) / 2, - r.width() - 2 * horizontalMargin, fm.height()); - QPainter painter(this); - painter.setPen(palette().brush(QPalette::Disabled, QPalette::Text).color()); - painter.drawText(lineRect, Qt::AlignLeft|Qt::AlignVCenter, m_inactiveText); - } else { - ExLineEdit::paintEvent(event); - } -} - -void SearchLineEdit::resizeEvent(QResizeEvent *event) -{ - updateGeometries(); - ExLineEdit::resizeEvent(event); -} - -void SearchLineEdit::updateGeometries() -{ - int menuHeight = height(); - int menuWidth = menuHeight + 1; - if (!m_searchButton->m_menu) - menuWidth = (menuHeight / 5) * 4; - m_searchButton->resize(QSize(menuWidth, menuHeight)); -} - -QString SearchLineEdit::inactiveText() const -{ - return m_inactiveText; -} - -void SearchLineEdit::setInactiveText(const QString &text) -{ - m_inactiveText = text; -} - -void SearchLineEdit::setMenu(QMenu *menu) -{ - if (m_searchButton->m_menu) - m_searchButton->m_menu->deleteLater(); - m_searchButton->m_menu = menu; - updateGeometries(); -} - -QMenu *SearchLineEdit::menu() const -{ - if (!m_searchButton->m_menu) { - m_searchButton->m_menu = new QMenu(m_searchButton); - if (isVisible()) - (const_cast(this))->updateGeometries(); - } - return m_searchButton->m_menu; -} diff --git a/src/searchlineedit.h b/src/searchlineedit.h deleted file mode 100644 index f7bbeb39..00000000 --- a/src/searchlineedit.h +++ /dev/null @@ -1,84 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef SEARCHLINEEDIT_H -#define SEARCHLINEEDIT_H - -// Local Includes -#include "urllineedit.h" - -// Qt Includes -#include -#include - -QT_BEGIN_NAMESPACE -class QMenu; -QT_END_NAMESPACE - -class SearchButton; - -/* - Clear button on the right hand side of the search widget. - Hidden by default - "A circle with an X in it" - */ -class ClearButton : public QAbstractButton -{ - Q_OBJECT - -public: - ClearButton(QWidget *parent = 0); - void paintEvent(QPaintEvent *event); - -public slots: - void textChanged(const QString &text); -}; - - -class SearchLineEdit : public ExLineEdit -{ - Q_OBJECT - Q_PROPERTY(QString inactiveText READ inactiveText WRITE setInactiveText) - -signals: - void textChanged(const QString &text); - -public: - SearchLineEdit(QWidget *parent = 0); - - QString inactiveText() const; - void setInactiveText(const QString &text); - - QMenu *menu() const; - void setMenu(QMenu *menu); - -protected: - void resizeEvent(QResizeEvent *event); - void paintEvent(QPaintEvent *event); - -private: - void updateGeometries(); - - SearchButton *m_searchButton; - QString m_inactiveText; -}; - -#endif // SEARCHLINEEDIT_H - diff --git a/src/urllineedit.cpp b/src/urllineedit.cpp deleted file mode 100644 index 88ce28c4..00000000 --- a/src/urllineedit.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#include "urllineedit.h" - -#include "browserapplication.h" -#include "searchlineedit.h" -#include "webview.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -ExLineEdit::ExLineEdit(QWidget *parent) - : QWidget(parent) - , m_leftWidget(0) - , m_lineEdit(new QLineEdit(this)) - , m_clearButton(0) -{ - setFocusPolicy(m_lineEdit->focusPolicy()); - setAttribute(Qt::WA_InputMethodEnabled); - setSizePolicy(m_lineEdit->sizePolicy()); - setBackgroundRole(m_lineEdit->backgroundRole()); - setMouseTracking(true); - setAcceptDrops(true); - setAttribute(Qt::WA_MacShowFocusRect, true); - QPalette p = m_lineEdit->palette(); - setPalette(p); - - // line edit - m_lineEdit->setFrame(false); - m_lineEdit->setFocusProxy(this); - m_lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false); - QPalette clearPalette = m_lineEdit->palette(); - clearPalette.setBrush(QPalette::Base, QBrush(Qt::transparent)); - m_lineEdit->setPalette(clearPalette); - - // clearButton - m_clearButton = new ClearButton(this); - connect(m_clearButton, SIGNAL(clicked()), m_lineEdit, SLOT(clear())); - connect(m_lineEdit, SIGNAL(textChanged(const QString&)), m_clearButton, SLOT(textChanged(const QString&))); -} - -void ExLineEdit::setLeftWidget(QWidget *widget) -{ - m_leftWidget = widget; -} - -QWidget *ExLineEdit::leftWidget() const -{ - return m_leftWidget; -} - -void ExLineEdit::resizeEvent(QResizeEvent *event) -{ - Q_ASSERT(m_leftWidget); - updateGeometries(); - QWidget::resizeEvent(event); -} - -void ExLineEdit::updateGeometries() -{ - QStyleOptionFrameV2 panel; - initStyleOption(&panel); - QRect rect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); - - int height = rect.height(); - int width = rect.width(); - - int m_leftWidgetHeight = m_leftWidget->height(); - m_leftWidget->setGeometry(rect.x() + 2, rect.y() + (height - m_leftWidgetHeight)/2, - m_leftWidget->width(), m_leftWidget->height()); - - int clearButtonWidth = this->height(); - m_lineEdit->setGeometry(m_leftWidget->x() + m_leftWidget->width(), 0, - width - clearButtonWidth - m_leftWidget->width(), this->height()); - - m_clearButton->setGeometry(this->width() - clearButtonWidth, 0, - clearButtonWidth, this->height()); -} - -void ExLineEdit::initStyleOption(QStyleOptionFrameV2 *option) const -{ - option->initFrom(this); - option->rect = contentsRect(); - option->lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, option, this); - option->midLineWidth = 0; - option->state |= QStyle::State_Sunken; - if (m_lineEdit->isReadOnly()) - option->state |= QStyle::State_ReadOnly; -#ifdef QT_KEYPAD_NAVIGATION - if (hasEditFocus()) - option->state |= QStyle::State_HasEditFocus; -#endif - option->features = QStyleOptionFrameV2::None; -} - -QSize ExLineEdit::sizeHint() const -{ - m_lineEdit->setFrame(true); - QSize size = m_lineEdit->sizeHint(); - m_lineEdit->setFrame(false); - return size; -} - -void ExLineEdit::focusInEvent(QFocusEvent *event) -{ - m_lineEdit->event(event); - QWidget::focusInEvent(event); -} - -void ExLineEdit::focusOutEvent(QFocusEvent *event) -{ - m_lineEdit->event(event); - - if (m_lineEdit->completer()) { - connect(m_lineEdit->completer(), SIGNAL(activated(QString)), - m_lineEdit, SLOT(setText(QString))); - connect(m_lineEdit->completer(), SIGNAL(highlighted(QString)), - m_lineEdit, SLOT(_q_completionHighlighted(QString))); - } - QWidget::focusOutEvent(event); -} - -void ExLineEdit::keyPressEvent(QKeyEvent *event) -{ - m_lineEdit->event(event); - QWidget::keyPressEvent(event); -} - -bool ExLineEdit::event(QEvent *event) -{ - if (event->type() == QEvent::ShortcutOverride) - m_lineEdit->event(event); - return QWidget::event(event); -} - -void ExLineEdit::paintEvent(QPaintEvent *) -{ - QPainter p(this); - QStyleOptionFrameV2 panel; - initStyleOption(&panel); - style()->drawPrimitive(QStyle::PE_PanelLineEdit, &panel, &p, this); -} - - -class UrlIconLabel : public QLabel -{ - -public: - UrlIconLabel(QWidget *parent); - - WebView *m_webView; - -protected: - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - -private: - QPoint m_dragStartPos; - -}; - -UrlIconLabel::UrlIconLabel(QWidget *parent) - : QLabel(parent) - , m_webView(0) -{ - setMinimumWidth(16); - setMinimumHeight(16); -} - -void UrlIconLabel::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - m_dragStartPos = event->pos(); - QLabel::mousePressEvent(event); -} - -void UrlIconLabel::mouseMoveEvent(QMouseEvent *event) -{ - if (event->buttons() == Qt::LeftButton - && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance() - && m_webView) { - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - mimeData->setText(m_webView->url().toString()); - QList urls; - urls.append(m_webView->url()); - mimeData->setUrls(urls); - drag->setMimeData(mimeData); - drag->exec(); - } -} - -UrlLineEdit::UrlLineEdit(QWidget *parent) - : ExLineEdit(parent) - , m_webView(0) - , m_iconLabel(0) -{ - // icon - m_iconLabel = new UrlIconLabel(this); - m_iconLabel->resize(16, 16); - setLeftWidget(m_iconLabel); - m_defaultBaseColor = palette().color(QPalette::Base); - - webViewIconChanged(); -} - -void UrlLineEdit::setWebView(WebView *webView) -{ - Q_ASSERT(!m_webView); - m_webView = webView; - m_iconLabel->m_webView = webView; - connect(webView, SIGNAL(urlChanged(const QUrl &)), - this, SLOT(webViewUrlChanged(const QUrl &))); - connect(webView, SIGNAL(loadFinished(bool)), - this, SLOT(webViewIconChanged())); - connect(webView, SIGNAL(iconChanged()), - this, SLOT(webViewIconChanged())); - connect(webView, SIGNAL(loadProgress(int)), - this, SLOT(update())); -} - -void UrlLineEdit::webViewUrlChanged(const QUrl &url) -{ - m_lineEdit->setText(url.toString()); - m_lineEdit->setCursorPosition(0); -} - -void UrlLineEdit::webViewIconChanged() -{ - QUrl url = (m_webView) ? m_webView->url() : QUrl(); - QIcon icon = BrowserApplication::instance()->icon(url); - QPixmap pixmap(icon.pixmap(16, 16)); - m_iconLabel->setPixmap(pixmap); -} - -QLinearGradient UrlLineEdit::generateGradient(const QColor &color) const -{ - QLinearGradient gradient(0, 0, 0, height()); - gradient.setColorAt(0, m_defaultBaseColor); - gradient.setColorAt(0.15, color.lighter(120)); - gradient.setColorAt(0.5, color); - gradient.setColorAt(0.85, color.lighter(120)); - gradient.setColorAt(1, m_defaultBaseColor); - return gradient; -} - -void UrlLineEdit::focusOutEvent(QFocusEvent *event) -{ - if (m_lineEdit->text().isEmpty() && m_webView) - m_lineEdit->setText(m_webView->url().toString()); - ExLineEdit::focusOutEvent(event); -} - -void UrlLineEdit::paintEvent(QPaintEvent *event) -{ - QPalette p = palette(); - if (m_webView && m_webView->url().scheme() == QLatin1String("https")) { - QColor lightYellow(248, 248, 210); - p.setBrush(QPalette::Base, generateGradient(lightYellow)); - } else { - p.setBrush(QPalette::Base, m_defaultBaseColor); - } - setPalette(p); - ExLineEdit::paintEvent(event); - - QPainter painter(this); - QStyleOptionFrameV2 panel; - initStyleOption(&panel); - QRect backgroundRect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); - if (m_webView && !hasFocus()) { - int progress = m_webView->progress(); - QColor loadingColor = QColor(116, 192, 250); - painter.setBrush(generateGradient(loadingColor)); - painter.setPen(Qt::transparent); - int mid = backgroundRect.width() / 100 * progress; - QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); - painter.drawRect(progressRect); - } -} diff --git a/src/urllineedit.h b/src/urllineedit.h deleted file mode 100644 index eca0c1f5..00000000 --- a/src/urllineedit.h +++ /dev/null @@ -1,93 +0,0 @@ -/* ============================================================ - * - * This file is a part of the reKonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef URLLINEEDIT_H -#define URLLINEEDIT_H - -// Qt Includes -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QLineEdit; -QT_END_NAMESPACE - -class ClearButton; -class ExLineEdit : public QWidget -{ - Q_OBJECT - -public: - ExLineEdit(QWidget *parent = 0); - - inline QLineEdit *lineEdit() const { return m_lineEdit; } - - void setLeftWidget(QWidget *widget); - QWidget *leftWidget() const; - - QSize sizeHint() const; - -protected: - void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); - void keyPressEvent(QKeyEvent *event); - void paintEvent(QPaintEvent *event); - void resizeEvent(QResizeEvent *event); - bool event(QEvent *event); - -protected: - void updateGeometries(); - void initStyleOption(QStyleOptionFrameV2 *option) const; - - QWidget *m_leftWidget; - QLineEdit *m_lineEdit; - ClearButton *m_clearButton; -}; - -class UrlIconLabel; -class WebView; -class UrlLineEdit : public ExLineEdit -{ - Q_OBJECT - -public: - UrlLineEdit(QWidget *parent = 0); - void setWebView(WebView *webView); - -protected: - void paintEvent(QPaintEvent *event); - void focusOutEvent(QFocusEvent *event); - -private slots: - void webViewUrlChanged(const QUrl &url); - void webViewIconChanged(); - -private: - QLinearGradient generateGradient(const QColor &color) const; - WebView *m_webView; - UrlIconLabel *m_iconLabel; - QColor m_defaultBaseColor; - -}; - - -#endif // URLLINEEDIT_H - -- cgit v1.2.1 From bc901b1e79acf8c49fb76c3aeabbf59a49fc8276 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 28 Nov 2008 10:58:12 +0100 Subject: Various adjustments. Nothing really important.Various adjustments. Nothing really important... --- src/browsermainwindow.cpp | 3 --- src/browsermainwindow.h | 1 - src/findbar.cpp | 18 +++++++++--------- src/findbar.h | 3 --- src/tabwidget.cpp | 11 +---------- src/tabwidget.h | 5 ++++- src/urlbar.cpp | 14 +++++++------- src/webview.cpp | 20 ++++++++++---------- src/webview.h | 6 +++--- 9 files changed, 34 insertions(+), 47 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 528beb13..cbf7eb54 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -398,9 +398,6 @@ void BrowserMainWindow::setupToolBar() m_searchBar = new SearchBar(m_navigationBar); m_navigationBar->addWidget(m_searchBar); connect(m_searchBar, SIGNAL(search(const QUrl&)), this, SLOT(loadUrl(const QUrl&))); -// m_toolbarSearch = new ToolbarSearch(m_navigationBar); -// m_navigationBar->addWidget(m_toolbarSearch); -// connect(m_toolbarSearch, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); } diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index fc57c6b9..349d2384 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -127,7 +127,6 @@ private: private: KToolBar *m_navigationBar; -// ToolbarSearch *m_toolbarSearch; SearchBar *m_searchBar; TabWidget *m_tabWidget; AutoSaver *m_autoSaver; diff --git a/src/findbar.cpp b/src/findbar.cpp index 45de4246..a0e1948d 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -90,15 +90,15 @@ void FindBar::showFind() -void FindBar::frameChanged(int frame) -{ -/* if (!m_widget) - return; - m_widget->move(0, frame); - int height = qMax(0, m_widget->y() + m_widget->height()); - setMinimumHeight(height); - setMaximumHeight(height);*/ -} +// void FindBar::frameChanged(int frame) +// { +// /* if (!m_widget) +// return; +// m_widget->move(0, frame); +// int height = qMax(0, m_widget->y() + m_widget->height()); +// setMinimumHeight(height); +// setMaximumHeight(height);*/ +// } void FindBar::slotFindNext() diff --git a/src/findbar.h b/src/findbar.h index 05dbf820..bd3c5960 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -40,9 +40,6 @@ public slots: void slotFindNext(); void slotFindPrevious(); -private slots: - void frameChanged(int frame); - private: void initializeFindWidget(); diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index ef3dc4ea..9ce8aa59 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -25,20 +25,11 @@ #include "browserapplication.h" #include "browsermainwindow.h" #include "history.h" -// #include "urllineedit.h" #include "urlbar.h" #include "webview.h" // Qt Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include diff --git a/src/tabwidget.h b/src/tabwidget.h index 63cd4e48..8e6d16b4 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -69,6 +69,9 @@ private: }; +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + #include @@ -103,7 +106,7 @@ private: }; - +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ #include #include diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 16783313..01675c3f 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -24,13 +24,13 @@ #include "browserapplication.h" // Qt Includes -#include -#include -#include -#include -#include -#include - +// #include +// #include +// #include +// #include +// #include +// #include +#include UrlBar::UrlBar(QWidget *parent) diff --git a/src/webview.cpp b/src/webview.cpp index 612a8a34..7cae61cf 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -108,16 +108,16 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) return mainWindow->currentTab()->page(); } -#if !defined(QT_NO_UITOOLS) -QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) -{ - Q_UNUSED(url); - Q_UNUSED(paramNames); - Q_UNUSED(paramValues); - QUiLoader loader; - return loader.createWidget(classId, view()); -} -#endif // !defined(QT_NO_UITOOLS) +// #if !defined(QT_NO_UITOOLS) +// QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +// { +// Q_UNUSED(url); +// Q_UNUSED(paramNames); +// Q_UNUSED(paramValues); +// QUiLoader loader; +// return loader.createWidget(classId, view()); +// } +// #endif // !defined(QT_NO_UITOOLS) void WebPage::handleUnsupportedContent(QNetworkReply *reply) { diff --git a/src/webview.h b/src/webview.h index 14fbc8aa..ccd44a6f 100644 --- a/src/webview.h +++ b/src/webview.h @@ -45,9 +45,9 @@ public: protected: bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); QWebPage *createWindow(QWebPage::WebWindowType type); -#if !defined(QT_NO_UITOOLS) - QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); -#endif +// #if !defined(QT_NO_UITOOLS) +// QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); +// #endif private slots: void handleUnsupportedContent(QNetworkReply *reply); -- cgit v1.2.1 From 129932ca513ed7ef865669fa81020043bcfa7ba0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 29 Nov 2008 12:15:17 +0100 Subject: Fixing ToolBar, some icons and code.. --- FEATURES | 2 +- icons/CMakeLists.txt | 1 + icons/hi-64-apps-rekonq.png | Bin 5650 -> 0 bytes icons/hi16-app-rekonq.png | Bin 0 -> 682 bytes icons/hi64-app-rekonq.png | Bin 0 -> 5650 bytes src/browserapplication.cpp | 35 ++++++++++---------- src/browsermainwindow.cpp | 10 ++++-- src/urlbar.cpp | 76 +++++++++++++++++++++----------------------- src/urlbar.h | 7 ++-- 9 files changed, 68 insertions(+), 63 deletions(-) delete mode 100644 icons/hi-64-apps-rekonq.png create mode 100644 icons/hi16-app-rekonq.png create mode 100644 icons/hi64-app-rekonq.png diff --git a/FEATURES b/FEATURES index 671155e6..43689398 100644 --- a/FEATURES +++ b/FEATURES @@ -2,7 +2,7 @@ TODO = - DONE = + - fully ported to KDE4 -- Kconfig support (obviously..) ++ Kconfig support (obviously..) - threadweaver support - kwallet support - dbus support diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt index 5d6766e8..9d7ead58 100644 --- a/icons/CMakeLists.txt +++ b/icons/CMakeLists.txt @@ -1 +1,2 @@ +# install standard icons KDE4_INSTALL_ICONS( ${ICON_INSTALL_DIR} ) diff --git a/icons/hi-64-apps-rekonq.png b/icons/hi-64-apps-rekonq.png deleted file mode 100644 index 312b572a..00000000 Binary files a/icons/hi-64-apps-rekonq.png and /dev/null differ diff --git a/icons/hi16-app-rekonq.png b/icons/hi16-app-rekonq.png new file mode 100644 index 00000000..2f3a9c01 Binary files /dev/null and b/icons/hi16-app-rekonq.png differ diff --git a/icons/hi64-app-rekonq.png b/icons/hi64-app-rekonq.png new file mode 100644 index 00000000..312b572a Binary files /dev/null and b/icons/hi64-app-rekonq.png differ diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 7a125bdc..3099dfc2 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -60,7 +60,8 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server { QLocalSocket socket; socket.connectToServer(serverName); - if (socket.waitForConnected(500)) { + if (socket.waitForConnected(500)) + { QTextStream stream(&socket); int n = args->count(); if (n > 1) @@ -96,7 +97,7 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server m_lastSession = settings.value(QLatin1String("lastSession")).toByteArray(); settings.endGroup(); - QTimer::singleShot(0, this, SLOT(postLaunch())); + QTimer::singleShot(0, this, SLOT( postLaunch() ) ); } @@ -111,15 +112,15 @@ BrowserApplication::~BrowserApplication() -#if defined(Q_WS_MAC) -void BrowserApplication::lastWindowClosed() -{ - clean(); - BrowserMainWindow *mw = new BrowserMainWindow; - mw->slotHome(); - m_mainWindows.prepend(mw); -} -#endif +// #if defined(Q_WS_MAC) +// void BrowserApplication::lastWindowClosed() +// { +// clean(); +// BrowserMainWindow *mw = new BrowserMainWindow; +// mw->slotHome(); +// m_mainWindows.prepend(mw); +// } +// #endif @@ -137,16 +138,18 @@ BrowserApplication *BrowserApplication::instance() void BrowserApplication::postLaunch() { QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - if (directory.isEmpty()) + if ( directory.isEmpty() ) + { directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); + } QWebSettings::setIconDatabasePath(directory); -// setWindowIcon(QIcon(QLatin1String(":browser.svg"))); // FIXME setICON - + setWindowIcon( KIcon("rekonq") ); loadSettings(); // newMainWindow() needs to be called in main() for this to happen - if (m_mainWindows.count() > 0) { + if (m_mainWindows.count() > 0) + { KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int n = args->count(); if (n > 1) @@ -395,7 +398,7 @@ KIcon BrowserApplication::icon(const QUrl &url) const if (!icon.isNull()) return icon; if (m_defaultIcon.isNull()) - m_defaultIcon = KIcon("rekonq"); + m_defaultIcon = KIcon("kde"); return m_defaultIcon; } diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index cbf7eb54..3a79f995 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -69,8 +69,9 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) , m_reload(0) , m_bookmarkMenu(0) { + // delete widget accepting close event setAttribute(Qt::WA_DeleteOnClose, true); - statusBar()->setSizeGripEnabled(true); + setupMenu(); setupToolBar(); @@ -372,7 +373,7 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { - m_navigationBar = (KToolBar *) addToolBar(i18n("Navigation")); + m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, true, false, false); m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); @@ -398,6 +399,11 @@ void BrowserMainWindow::setupToolBar() m_searchBar = new SearchBar(m_navigationBar); m_navigationBar->addWidget(m_searchBar); connect(m_searchBar, SIGNAL(search(const QUrl&)), this, SLOT(loadUrl(const QUrl&))); + + // UI settings + m_navigationBar->setIconDimensions(16); + m_navigationBar->setContextMenuPolicy( Qt::NoContextMenu ); + KToolBar::setToolBarsLocked( true ); } diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 01675c3f..07b5168b 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -24,12 +24,6 @@ #include "browserapplication.h" // Qt Includes -// #include -// #include -// #include -// #include -// #include -// #include #include @@ -45,16 +39,19 @@ UrlBar::UrlBar(QWidget *parent) m_lineEdit = new KLineEdit; - QVBoxLayout *layout = new QVBoxLayout; + QHBoxLayout *layout = new QHBoxLayout; layout->addWidget(m_iconLabel); layout->addWidget(m_lineEdit); setLayout(layout); m_defaultBaseColor = palette().color(QPalette::Base); + setPalette( QPalette(Qt::white) ); + setAutoFillBackground( true ); webViewIconChanged(); } + UrlBar::~UrlBar() { // delete m_webView; @@ -62,11 +59,13 @@ UrlBar::~UrlBar() delete m_lineEdit; } + KLineEdit *UrlBar::lineEdit() { return m_lineEdit; } + void UrlBar::setWebView(WebView *webView) { Q_ASSERT(!m_webView); @@ -78,39 +77,6 @@ void UrlBar::setWebView(WebView *webView) connect(webView, SIGNAL(loadProgress(int)), this, SLOT(update())); } -void UrlBar::paintEvent(QPaintEvent *event) -{ - QPainter p(this); - QStyleOptionFrameV2 optionPanel; - - optionPanel.initFrom(this); - optionPanel.rect = contentsRect(); - optionPanel.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &optionPanel, this); - optionPanel.midLineWidth = 0; - optionPanel.state |= QStyle::State_Sunken; - if (m_lineEdit->isReadOnly()) - optionPanel.state |= QStyle::State_ReadOnly; - optionPanel.features = QStyleOptionFrameV2::None; - - style()->drawPrimitive(QStyle::PE_PanelLineEdit, &optionPanel, &p, (QWidget *) this); -} - -void UrlBar::focusOutEvent(QFocusEvent *event) -{ - if (m_lineEdit->text().isEmpty() && m_webView) - { - m_lineEdit->setText(m_webView->url().toString()); - } - -// m_lineEdit->event(event); // FIXME - - if (m_lineEdit->completer()) - { - connect(m_lineEdit->completer(), SIGNAL(activated(QString)), m_lineEdit, SLOT(setText(QString))); - connect(m_lineEdit->completer(), SIGNAL(highlighted(QString)), m_lineEdit, SLOT(_q_completionHighlighted(QString))); - } - QWidget::focusOutEvent(event); -} void UrlBar::webViewUrlChanged(const QUrl &url) { @@ -118,6 +84,7 @@ void UrlBar::webViewUrlChanged(const QUrl &url) m_lineEdit->setCursorPosition(0); } + void UrlBar::webViewIconChanged() { QUrl url = (m_webView) ? m_webView->url() : QUrl(); @@ -126,6 +93,7 @@ void UrlBar::webViewIconChanged() m_iconLabel->setPixmap(pixmap); } + QLinearGradient UrlBar::generateGradient(const QColor &color) const { QLinearGradient gradient(0, 0, 0, height()); @@ -137,3 +105,31 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const return gradient; } +// FIXME +// void UrlBar::paintEvent(QPaintEvent *event) +// { +// QPalette p = palette(); +// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) { +// QColor lightYellow(248, 248, 210); +// p.setBrush(QPalette::Base, generateGradient(lightYellow)); +// } else { +// p.setBrush(QPalette::Base, m_defaultBaseColor); +// } +// setPalette(p); +// +// QPainter painter(this); +// QStyleOptionFrameV2 panel; +// // initStyleOption(&panel); +// QRect backgroundRect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); +// if (m_webView && !hasFocus()) +// { +// int progress = m_webView->progress(); +// QColor loadingColor = QColor(116, 192, 250); +// painter.setBrush(generateGradient(loadingColor)); +// painter.setPen(Qt::transparent); +// int mid = backgroundRect.width() / 100 * progress; +// QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); +// painter.drawRect(progressRect); +// } +// } + diff --git a/src/urlbar.h b/src/urlbar.h index db6304da..56ba7686 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -40,12 +40,11 @@ public: ~UrlBar(); KLineEdit *lineEdit(); - void setWebView(WebView *webView); -protected: - void paintEvent(QPaintEvent *event); - void focusOutEvent(QFocusEvent *event); +// FIXME needed to color urlbar while loading urls +// protected: +// void paintEvent(QPaintEvent *event); private slots: void webViewUrlChanged(const QUrl &url); -- cgit v1.2.1 From d62176f7f2a6a204b5017bc661fff2d3a9f76e6e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 30 Nov 2008 17:30:57 +0100 Subject: - Ported historyMenu to KAction - some adjs on urlbar - added TODO file to remember things --- TODO | 20 ++++++++ src/browsermainwindow.cpp | 48 ++++++++----------- src/browsermainwindow.h | 9 ++-- src/findbar.cpp | 78 ++++++++++++++---------------- src/findbar.h | 16 ++++--- src/history.cpp | 120 ++++++++++++++++++++++++++++++++++++++++++---- src/history.h | 23 ++++++++- src/modelmenu.cpp | 46 ++++++++++++------ src/modelmenu.h | 13 +++-- src/urlbar.cpp | 4 +- src/urlbar.h | 1 + 11 files changed, 266 insertions(+), 112 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 00000000..78f0f8a8 --- /dev/null +++ b/TODO @@ -0,0 +1,20 @@ +Road to 0.0.1 (first release) ++ ESC event findbar ++ let findbar work +- bookmarks (share konqueror's) +- some porting + +NEXT.. +- better FULL SCREEN +- simplify history +- QUrl --> KUrl +- KDE download = Kjob && Kget +- adjust toolbar(s) + -search bar + - url bar +- KDEize menubar (settings) +- configure dialog (A-LA amarok, konqueror) +- dbus support (?!) +- KWallet support + +- Kpart ?? diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 3a79f995..0bf8b0ef 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -84,8 +84,8 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) layout->addWidget(m_tabWidget); // Find Bar - m_findBar = new FindBar(centralWidget); - layout->addWidget(m_findBar); + m_findBar = new FindBar(this); + connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); centralWidget->setLayout(layout); setCentralWidget(centralWidget); @@ -271,8 +271,8 @@ void BrowserMainWindow::setupMenu() editMenu->addSeparator(); editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); - editMenu->addAction( KStandardAction::findNext(this, SLOT( slotEditFindNext() ) , this ) ); - editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotEditFindPrevious() ) , this ) ); + editMenu->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); + editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); editMenu->addSeparator(); @@ -313,7 +313,7 @@ void BrowserMainWindow::setupMenu() connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle( i18n("Hi&story") ); menuBar()->addMenu(historyMenu); - QList historyActions; + QList historyActions; m_historyBack = new KAction( i18n("Back"), this); m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); @@ -325,7 +325,7 @@ void BrowserMainWindow::setupMenu() // m_historyForward->setShortcuts(QKeySequence::Forward); FIXME m_historyForward->setIconVisibleInMenu(false); - m_restoreLastSession = new QAction( i18n("Restore Last Session"), this); + m_restoreLastSession = new KAction( i18n("Restore Last Session"), this); connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); @@ -653,33 +653,26 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event) } -// FIXME: reimplement me A-LA KATE search bar -void BrowserMainWindow::slotEditFind() +void BrowserMainWindow::slotFind(const QString & search) { -// if (!currentTab()) -// return; -// bool ok; -// QString search = QInputDialog::getText(this, i18n("Find"), -// i18n("Text:"), QLineEdit::Normal, -// m_lastSearch, &ok); -// if (ok && !search.isEmpty()) { -// m_lastSearch = search; -// if (!currentTab()->findText(m_lastSearch)) -// slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); -// } -// m_findWidg->setVisible( true ); -/*if ( !currentTab() ) - return; -bool ok; -m_lastSearch = findWidg->*/ + if (!currentTab()) + return; + if (!search.isEmpty()) + { + m_lastSearch = search; + if (!currentTab()->findText(m_lastSearch)) + slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + } } + void BrowserMainWindow::slotViewFindBar() { - m_findBar->show(); + m_findBar->showFindBar(); } -void BrowserMainWindow::slotEditFindNext() + +void BrowserMainWindow::slotFindNext() { if (!currentTab() && !m_lastSearch.isEmpty()) return; @@ -687,8 +680,7 @@ void BrowserMainWindow::slotEditFindNext() } - -void BrowserMainWindow::slotEditFindPrevious() +void BrowserMainWindow::slotFindPrevious() { if (!currentTab() && !m_lastSearch.isEmpty()) return; diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 349d2384..5ead8dda 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -67,6 +67,9 @@ public: public slots: void loadPage(const QString &url); void slotHome(); + void slotFind(const QString &); + void slotFindNext(); + void slotFindPrevious(); protected: void closeEvent(QCloseEvent *event); @@ -87,9 +90,7 @@ private slots: void slotFilePrint(); void slotPrivateBrowsing(); void slotFileSaveAs(); - void slotEditFind(); - void slotEditFindNext(); - void slotEditFindPrevious(); + void slotAddBookmark(); void slotViewTextBigger(); void slotViewTextNormal(); @@ -141,7 +142,7 @@ private: KAction *m_stopReload; KAction *m_goHome; KAction *m_viewStatusbar; - QAction *m_restoreLastSession; + KAction *m_restoreLastSession; KAction *m_addBookmark; KIcon m_reloadIcon; diff --git a/src/findbar.cpp b/src/findbar.cpp index a0e1948d..2d9e0d5c 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -25,14 +25,31 @@ #include #include #include +#include #include -FindBar::FindBar(QWidget *parent) - : KToolBar(parent) +FindBar::FindBar(QMainWindow *parent) + : KToolBar( "FindBar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) { - initializeFindWidget(); + KAction *close = new KAction(KIcon("dialog-close") , "close" , this); + connect( close , SIGNAL( triggered() ), this, SLOT( hide() ) ); + addAction( close ); + + QLabel *label = new QLabel("Find: "); + addWidget( label ); + + m_lineEdit = new KLineEdit(); + connect( m_lineEdit, SIGNAL( returnPressed() ), parent, SLOT( slotFindNext() ) ); + connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), parent, SLOT( slotFindNext() ) ); + addWidget( m_lineEdit ); + + addAction( KStandardAction::findNext(parent, SLOT( slotFindNext() ) , this ) ); + addAction( KStandardAction::findPrev(parent, SLOT( slotFindPrevious() ) , this ) ); + + QLabel *spaceLabel = new QLabel(" "); // FIXME + addWidget( spaceLabel ); // we start off hidden hide(); @@ -51,34 +68,13 @@ KLineEdit *FindBar::lineEdit() } -void FindBar::initializeFindWidget() -{ - addAction( KIcon("dialog-close") , "close" , this, SLOT( hide() ) ); - - QLabel *label = new QLabel("Find: "); - addWidget( label ); - - m_lineEdit = new KLineEdit(); - connect( m_lineEdit, SIGNAL( returnPressed() ), this, SLOT( slotFindNext() ) ); - connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), this, SLOT( slotFindNext() ) ); - addWidget( m_lineEdit ); - - addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); - - QLabel *spaceLabel = new QLabel(" "); // FIXME - addWidget( spaceLabel ); -} - - - void FindBar::clear() { m_lineEdit->setText(QString()); } -void FindBar::showFind() +void FindBar::showFindBar() { if (!isVisible()) { @@ -89,21 +85,17 @@ void FindBar::showFind() } - -// void FindBar::frameChanged(int frame) -// { -// /* if (!m_widget) -// return; -// m_widget->move(0, frame); -// int height = qMax(0, m_widget->y() + m_widget->height()); -// setMinimumHeight(height); -// setMaximumHeight(height);*/ -// } - - -void FindBar::slotFindNext() -{} - -void FindBar::slotFindPrevious() -{} - +void FindBar::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Escape) + { + hide(); + return; + } + if(event->key() == Qt::Key_Return && ! ( m_lineEdit->text().isEmpty() ) ) + { + emit searchString( m_lineEdit->text() ); + return; + } + QWidget::keyPressEvent(event); +} diff --git a/src/findbar.h b/src/findbar.h index bd3c5960..ece34f83 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -23,26 +23,28 @@ #include #include -#include +#include class FindBar : public KToolBar { Q_OBJECT public: - FindBar(QWidget *parent = 0); + FindBar(QMainWindow *parent); ~FindBar(); KLineEdit *lineEdit(); public slots: void clear(); - void showFind(); - void slotFindNext(); - void slotFindPrevious(); + void showFindBar(); + +protected Q_SLOTS: + void keyPressEvent(QKeyEvent* event); -private: - void initializeFindWidget(); +signals: + void searchString(const QString &); +private: KLineEdit *m_lineEdit; QWidget *m_centralWidget; }; diff --git a/src/history.cpp b/src/history.cpp index ea322b65..cb6e80b0 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -44,8 +44,10 @@ #include + static const unsigned int HISTORY_VERSION = 23; + HistoryManager::HistoryManager(QObject *parent) : QWebHistoryInterface(parent) , m_saveTimer(new AutoSaver(this)) @@ -68,21 +70,25 @@ HistoryManager::HistoryManager(QObject *parent) QWebHistoryInterface::setDefaultInterface(this); } + HistoryManager::~HistoryManager() { m_saveTimer->saveIfNeccessary(); } + QList HistoryManager::history() const { return m_history; } + bool HistoryManager::historyContains(const QString &url) const { return m_historyFilterModel->historyContains(url); } + void HistoryManager::addHistoryEntry(const QString &url) { QUrl cleanUrl(url); @@ -92,6 +98,7 @@ void HistoryManager::addHistoryEntry(const QString &url) addHistoryItem(item); } + void HistoryManager::setHistory(const QList &history, bool loadedAndSorted) { m_history = history; @@ -111,21 +118,25 @@ void HistoryManager::setHistory(const QList &history, bool loadedAn emit historyReset(); } + HistoryModel *HistoryManager::historyModel() const { return m_historyModel; } + HistoryFilterModel *HistoryManager::historyFilterModel() const { return m_historyFilterModel; } + HistoryTreeModel *HistoryManager::historyTreeModel() const { return m_historyTreeModel; } + void HistoryManager::checkForExpired() { if (m_historyLimit < 0 || m_history.isEmpty()) @@ -155,6 +166,7 @@ void HistoryManager::checkForExpired() m_expiredTimer.start(nextTimeout * 1000); } + void HistoryManager::addHistoryItem(const HistoryItem &item) { QWebSettings *globalSettings = QWebSettings::globalSettings(); @@ -167,6 +179,8 @@ void HistoryManager::addHistoryItem(const HistoryItem &item) checkForExpired(); } + + void HistoryManager::updateHistoryItem(const QUrl &url, const QString &title) { for (int i = 0; i < m_history.count(); ++i) { @@ -181,11 +195,13 @@ void HistoryManager::updateHistoryItem(const QUrl &url, const QString &title) } } + int HistoryManager::historyLimit() const { return m_historyLimit; } + void HistoryManager::setHistoryLimit(int limit) { if (m_historyLimit == limit) @@ -195,6 +211,7 @@ void HistoryManager::setHistoryLimit(int limit) m_saveTimer->changeOccurred(); } + void HistoryManager::clear() { m_history.clear(); @@ -204,6 +221,7 @@ void HistoryManager::clear() historyReset(); } + void HistoryManager::loadSettings() { // load settings @@ -212,6 +230,8 @@ void HistoryManager::loadSettings() m_historyLimit = settings.value(QLatin1String("historyLimit"), 30).toInt(); } + + void HistoryManager::load() { loadSettings(); @@ -275,6 +295,7 @@ void HistoryManager::load() } } + void HistoryManager::save() { QSettings settings; @@ -339,6 +360,10 @@ void HistoryManager::save() m_lastSavedUrl = m_history.value(0).url; } + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) : QAbstractTableModel(parent) , m_history(history) @@ -350,23 +375,27 @@ HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) connect(m_history, SIGNAL(entryUpdated(int)), this, SLOT(entryUpdated(int))); } + void HistoryModel::historyReset() { reset(); } + void HistoryModel::entryAdded() { beginInsertRows(QModelIndex(), 0, 0); endInsertRows(); } + void HistoryModel::entryUpdated(int offset) { QModelIndex idx = index(offset, 0); emit dataChanged(idx, idx); } + QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal @@ -379,6 +408,7 @@ QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int return QAbstractTableModel::headerData(section, orientation, role); } + QVariant HistoryModel::data(const QModelIndex &index, int role) const { QList lst = m_history->history(); @@ -419,16 +449,19 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const return QVariant(); } + int HistoryModel::columnCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : 2; } + int HistoryModel::rowCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : m_history->history().count(); } + bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent) { if (parent.isValid()) @@ -445,6 +478,10 @@ bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent) return true; } + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + #define MOVEDROWS 15 /* @@ -563,23 +600,27 @@ QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const } +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HistoryMenu::HistoryMenu(QWidget *parent) : ModelMenu(parent) , m_history(0) { - connect(this, SIGNAL(activated(const QModelIndex &)), - this, SLOT(activated(const QModelIndex &))); + connect(this, SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); setHoverRole(HistoryModel::UrlStringRole); } + void HistoryMenu::activated(const QModelIndex &index) { emit openUrl(index.data(HistoryModel::UrlRole).toUrl()); } + bool HistoryMenu::prePopulated() { - if (!m_history) { + if (!m_history) + { m_history = BrowserApplication::historyManager(); m_historyMenuModel = new HistoryMenuModel(m_history->historyTreeModel(), this); setModel(m_historyMenuModel); @@ -594,41 +635,47 @@ bool HistoryMenu::prePopulated() return false; } + void HistoryMenu::postPopulated() { if (m_history->history().count() > 0) addSeparator(); - QAction *showAllAction = new QAction( i18n("Show All History"), this); + KAction *showAllAction = new KAction( i18n("Show All History"), this); connect(showAllAction, SIGNAL(triggered()), this, SLOT(showHistoryDialog())); addAction(showAllAction); - QAction *clearAction = new QAction( i18n("Clear History"), this); + KAction *clearAction = new KAction( i18n("Clear History"), this); connect(clearAction, SIGNAL(triggered()), m_history, SLOT(clear())); addAction(clearAction); } + void HistoryMenu::showHistoryDialog() { HistoryDialog *dialog = new HistoryDialog(this); - connect(dialog, SIGNAL(openUrl(const QUrl&)), - this, SIGNAL(openUrl(const QUrl&))); + connect(dialog, SIGNAL(openUrl(const QUrl&)), this, SIGNAL(openUrl(const QUrl&))); dialog->show(); } -void HistoryMenu::setInitialActions(QList actions) + +void HistoryMenu::setInitialActions(QList actions) { m_initialActions = actions; for (int i = 0; i < m_initialActions.count(); ++i) addAction(m_initialActions.at(i)); } + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + TreeProxyModel::TreeProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { setSortRole(HistoryModel::DateTimeRole); setFilterCaseSensitivity(Qt::CaseInsensitive); } + bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const { if (!source_parent.isValid()) @@ -636,6 +683,9 @@ bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_ return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent); } + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HistoryDialog::HistoryDialog(QWidget *parent, HistoryManager *setHistory) : QDialog(parent) { HistoryManager *history = setHistory; @@ -666,6 +716,7 @@ HistoryDialog::HistoryDialog(QWidget *parent, HistoryManager *setHistory) : QDia this, SLOT(customContextMenuRequested(const QPoint &))); } + void HistoryDialog::customContextMenuRequested(const QPoint &pos) { QMenu menu; @@ -680,6 +731,7 @@ void HistoryDialog::customContextMenuRequested(const QPoint &pos) menu.exec(QCursor::pos()); } + void HistoryDialog::open() { QModelIndex index = tree->currentIndex(); @@ -688,6 +740,7 @@ void HistoryDialog::open() emit openUrl(index.data(HistoryModel::UrlRole).toUrl()); } + void HistoryDialog::copy() { QModelIndex index = tree->currentIndex(); @@ -699,6 +752,9 @@ void HistoryDialog::copy() clipboard->setText(url); } + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent) : QAbstractProxyModel(parent), m_loaded(false) @@ -706,6 +762,7 @@ HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject setSourceModel(sourceModel); } + int HistoryFilterModel::historyLocation(const QString &url) const { load(); @@ -714,11 +771,13 @@ int HistoryFilterModel::historyLocation(const QString &url) const return sourceModel()->rowCount() - m_historyHash.value(url); } + QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const { return QAbstractProxyModel::data(index, role); } + void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) { if (sourceModel()) { @@ -745,22 +804,26 @@ void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) } } + void HistoryFilterModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { emit dataChanged(mapFromSource(topLeft), mapFromSource(bottomRight)); } + QVariant HistoryFilterModel::headerData(int section, Qt::Orientation orientation, int role) const { return sourceModel()->headerData(section, orientation, role); } + void HistoryFilterModel::sourceReset() { m_loaded = false; reset(); } + int HistoryFilterModel::rowCount(const QModelIndex &parent) const { load(); @@ -769,11 +832,13 @@ int HistoryFilterModel::rowCount(const QModelIndex &parent) const return m_historyHash.count(); } + int HistoryFilterModel::columnCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : 2; } + QModelIndex HistoryFilterModel::mapToSource(const QModelIndex &proxyIndex) const { load(); @@ -781,6 +846,7 @@ QModelIndex HistoryFilterModel::mapToSource(const QModelIndex &proxyIndex) const return sourceModel()->index(sourceRow, proxyIndex.column()); } + QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) const { load(); @@ -807,6 +873,7 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co return createIndex(realRow, sourceIndex.column(), sourceModel()->rowCount() - sourceIndex.row()); } + QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &parent) const { load(); @@ -817,11 +884,13 @@ QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &pa return createIndex(row, column, m_sourceRow[row]); } + QModelIndex HistoryFilterModel::parent(const QModelIndex &) const { return QModelIndex(); } + void HistoryFilterModel::load() const { if (m_loaded) @@ -840,6 +909,7 @@ void HistoryFilterModel::load() const m_loaded = true; } + void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start, int end) { Q_ASSERT(start == end && start == 0); @@ -862,6 +932,7 @@ void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start endInsertRows(); } + void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int end) { Q_UNUSED(start); @@ -869,6 +940,9 @@ void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int e sourceReset(); } + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* Removing a continuous block of rows will remove filtered rows too as this is the users intention. @@ -894,11 +968,13 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren return true; } + HistoryCompletionModel::HistoryCompletionModel(QObject *parent) : QAbstractProxyModel(parent) { } + QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const { if (sourceModel() @@ -919,22 +995,26 @@ QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const return QAbstractProxyModel::data(index, role); } + int HistoryCompletionModel::rowCount(const QModelIndex &parent) const { return (parent.isValid() || !sourceModel()) ? 0 : sourceModel()->rowCount(parent) * 2; } + int HistoryCompletionModel::columnCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : 1; } + QModelIndex HistoryCompletionModel::mapFromSource(const QModelIndex &sourceIndex) const { int row = sourceIndex.row() * 2; return index(row, sourceIndex.column()); } + QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) const { if (!sourceModel()) @@ -943,6 +1023,7 @@ QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) c return sourceModel()->index(row, proxyIndex.column()); } + QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 || row >= rowCount(parent) @@ -951,11 +1032,13 @@ QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex return createIndex(row, column, 0); } + QModelIndex HistoryCompletionModel::parent(const QModelIndex &) const { return QModelIndex(); } + void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) { if (sourceModel()) { @@ -979,22 +1062,29 @@ void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) reset(); } + void HistoryCompletionModel::sourceReset() { reset(); } + + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent) : QAbstractProxyModel(parent) { setSourceModel(sourceModel); } + QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation, int role) const { return sourceModel()->headerData(section, orientation, role); } + QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const { if ((role == Qt::EditRole || role == Qt::DisplayRole)) { @@ -1024,11 +1114,13 @@ QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const return QAbstractProxyModel::data(index, role); } + int HistoryTreeModel::columnCount(const QModelIndex &parent) const { return sourceModel()->columnCount(mapToSource(parent)); } + int HistoryTreeModel::rowCount(const QModelIndex &parent) const { if ( parent.internalId() != 0 @@ -1062,6 +1154,7 @@ int HistoryTreeModel::rowCount(const QModelIndex &parent) const return (end - start); } + // Translate the top level date row into the offset where that date starts int HistoryTreeModel::sourceDateRow(int row) const { @@ -1079,6 +1172,7 @@ int HistoryTreeModel::sourceDateRow(int row) const return m_sourceRowCache.at(row); } + QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const { int offset = proxyIndex.internalId(); @@ -1088,6 +1182,7 @@ QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const return sourceModel()->index(startDateRow + proxyIndex.row(), proxyIndex.column()); } + QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 @@ -1100,6 +1195,7 @@ QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &pare return createIndex(row, column, parent.row() + 1); } + QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const { int offset = index.internalId(); @@ -1108,6 +1204,7 @@ QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const return createIndex(offset - 1, 0, 0); } + bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const { QModelIndex grandparent = parent.parent(); @@ -1116,6 +1213,7 @@ bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const return false; } + Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const { if (!index.isValid()) @@ -1123,6 +1221,7 @@ Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled; } + bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) { if (row < 0 || count <= 0 || row + count > rowCount(parent)) @@ -1144,6 +1243,7 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) return true; } + void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) { if (sourceModel()) { @@ -1169,12 +1269,14 @@ void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) reset(); } + void HistoryTreeModel::sourceReset() { m_sourceRowCache.clear(); reset(); } + void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, int end) { Q_UNUSED(parent); // Avoid warnings when compiling release @@ -1197,6 +1299,7 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, } } + QModelIndex HistoryTreeModel::mapFromSource(const QModelIndex &sourceIndex) const { if (!sourceIndex.isValid()) @@ -1214,6 +1317,7 @@ QModelIndex HistoryTreeModel::mapFromSource(const QModelIndex &sourceIndex) cons return createIndex(row, sourceIndex.column(), dateRow + 1); } + void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, int end) { Q_UNUSED(parent); // Avoid warnings when compiling release diff --git a/src/history.h b/src/history.h index 80b9f517..97d7f34e 100644 --- a/src/history.h +++ b/src/history.h @@ -34,6 +34,10 @@ #include #include +// KDE Includes +#include + + class HistoryItem { public: @@ -55,10 +59,15 @@ public: QDateTime dateTime; }; + + + class AutoSaver; class HistoryModel; class HistoryFilterModel; class HistoryTreeModel; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ class HistoryManager : public QWebHistoryInterface { Q_OBJECT @@ -115,6 +124,8 @@ private: HistoryTreeModel *m_historyTreeModel; }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ class HistoryModel : public QAbstractTableModel { Q_OBJECT @@ -143,6 +154,8 @@ private: HistoryManager *m_history; }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /*! Proxy model that will remove any duplicate entries. Both m_sourceRow and m_historyHash store their offsets not from @@ -184,6 +197,8 @@ private: mutable bool m_loaded; }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* The history menu - Removes the first twenty entries and puts them as children of the top level. @@ -211,6 +226,8 @@ private: HistoryTreeModel *m_treeModel; }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // Menu that is dynamically populated from the history class HistoryMenu : public ModelMenu { @@ -221,7 +238,7 @@ signals: public: HistoryMenu(QWidget *parent = 0); - void setInitialActions(QList actions); + void setInitialActions(QList actions); protected: bool prePopulated(); @@ -234,9 +251,11 @@ private slots: private: HistoryManager *m_history; HistoryMenuModel *m_historyMenuModel; - QList m_initialActions; + QList m_initialActions; }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // proxy model for the history model that // exposes each url http://www.foo.com and it url starting at the host www.foo.com class HistoryCompletionModel : public QAbstractProxyModel diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp index 3f543a1f..7c8fb128 100644 --- a/src/modelmenu.cpp +++ b/src/modelmenu.cpp @@ -20,8 +20,6 @@ #include "modelmenu.h" -#include -#include ModelMenu::ModelMenu(QWidget * parent) : QMenu(parent) @@ -35,81 +33,98 @@ ModelMenu::ModelMenu(QWidget * parent) connect(this, SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); } + bool ModelMenu::prePopulated() { return false; } + void ModelMenu::postPopulated() { } + void ModelMenu::setModel(QAbstractItemModel *model) { m_model = model; } + QAbstractItemModel *ModelMenu::model() const { return m_model; } + void ModelMenu::setMaxRows(int max) { m_maxRows = max; } + int ModelMenu::maxRows() const { return m_maxRows; } + void ModelMenu::setFirstSeparator(int offset) { m_firstSeparator = offset; } + int ModelMenu::firstSeparator() const { return m_firstSeparator; } + void ModelMenu::setRootIndex(const QModelIndex &index) { m_root = index; } + QModelIndex ModelMenu::rootIndex() const { return m_root; } + void ModelMenu::setHoverRole(int role) { m_hoverRole = role; } + int ModelMenu::hoverRole() const { return m_hoverRole; } + void ModelMenu::setSeparatorRole(int role) { m_separatorRole = role; } + int ModelMenu::separatorRole() const { return m_separatorRole; } + Q_DECLARE_METATYPE(QModelIndex) void ModelMenu::aboutToShow() { - if (QMenu *menu = qobject_cast(sender())) { + if (QMenu *menu = qobject_cast(sender())) + { QVariant v = menu->menuAction()->data(); - if (v.canConvert()) { + if (v.canConvert()) + { QModelIndex idx = qvariant_cast(v); createMenu(idx, -1, menu, menu); disconnect(menu, SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); @@ -129,7 +144,8 @@ void ModelMenu::aboutToShow() void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu, QMenu *menu) { - if (!menu) { + if (!menu) + { QString title = parent.data().toString(); menu = new QMenu(title, this); QIcon icon = qvariant_cast(parent.data(Qt::DecorationRole)); @@ -146,8 +162,8 @@ void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu if (max != -1) end = qMin(max, end); - connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*))); - connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(hovered(QAction*))); + connect(menu, SIGNAL( triggered(QAction*) ), this, SLOT( triggered(QAction*) ) ); + connect(menu, SIGNAL( hovered(QAction*) ), this, SLOT( hovered(QAction*) ) ); for (int i = 0; i < end; ++i) { QModelIndex idx = m_model->index(i, 0, parent); @@ -165,29 +181,30 @@ void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu } } -QAction *ModelMenu::makeAction(const QModelIndex &index) +KAction *ModelMenu::makeAction(const QModelIndex &index) { - QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); - QAction *action = makeAction(icon, index.data().toString(), this); + QIcon icon = qvariant_cast( index.data(Qt::DecorationRole) ); + KAction *action = (KAction *) makeAction(KIcon(icon), index.data().toString(), this); QVariant v; v.setValue(index); action->setData(v); return action; } -QAction *ModelMenu::makeAction(const QIcon &icon, const QString &text, QObject *parent) +KAction *ModelMenu::makeAction(const KIcon &icon, const QString &text, QObject *parent) { QFontMetrics fm(font()); if (-1 == m_maxWidth) m_maxWidth = fm.width(QLatin1Char('m')) * 30; QString smallText = fm.elidedText(text, Qt::ElideMiddle, m_maxWidth); - return new QAction(icon, smallText, parent); + return new KAction(icon, smallText, parent); } void ModelMenu::triggered(QAction *action) { QVariant v = action->data(); - if (v.canConvert()) { + if (v.canConvert()) + { QModelIndex idx = qvariant_cast(v); emit activated(idx); } @@ -196,7 +213,8 @@ void ModelMenu::triggered(QAction *action) void ModelMenu::hovered(QAction *action) { QVariant v = action->data(); - if (v.canConvert()) { + if (v.canConvert()) + { QModelIndex idx = qvariant_cast(v); QString hoveredString = idx.data(m_hoverRole).toString(); if (!hoveredString.isEmpty()) diff --git a/src/modelmenu.h b/src/modelmenu.h index d539d6bf..61ec370b 100644 --- a/src/modelmenu.h +++ b/src/modelmenu.h @@ -22,8 +22,13 @@ #ifndef MODELMENU_H #define MODELMENU_H -#include -#include +// Qt Includes +#include +#include + +// KDE Includes +#include +#include // A QMenu that is dynamically populated from a QAbstractItemModel class ModelMenu : public QMenu @@ -55,7 +60,7 @@ public: void setSeparatorRole(int role); int separatorRole() const; - QAction *makeAction(const QIcon &icon, const QString &text, QObject *parent); + KAction *makeAction(const KIcon &icon, const QString &text, QObject *parent); protected: // add any actions before the tree, return true if any actions are added. @@ -71,7 +76,7 @@ private slots: void hovered(QAction *action); private: - QAction *makeAction(const QModelIndex &index); + KAction *makeAction(const QModelIndex &index); int m_maxRows; int m_firstSeparator; int m_maxWidth; diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 07b5168b..cde55cb3 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -45,8 +45,8 @@ UrlBar::UrlBar(QWidget *parent) setLayout(layout); m_defaultBaseColor = palette().color(QPalette::Base); - setPalette( QPalette(Qt::white) ); - setAutoFillBackground( true ); +// setPalette( QPalette(Qt::white) ); + setAutoFillBackground( false ); webViewIconChanged(); } diff --git a/src/urlbar.h b/src/urlbar.h index 56ba7686..72b64654 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -25,6 +25,7 @@ // KDE Includes #include +#include // Qt Includes #include -- cgit v1.2.1 From 6efdfa17dd017d735364626220b501cb2063e1c9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 1 Dec 2008 01:09:56 +0100 Subject: New BookmarkMenu implementation --- src/bookmarks.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++ src/bookmarks.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ src/browsermainwindow.cpp | 7 +++--- 3 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 src/bookmarks.cpp create mode 100644 src/bookmarks.h diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp new file mode 100644 index 00000000..29c175e8 --- /dev/null +++ b/src/bookmarks.cpp @@ -0,0 +1,58 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#include "bookmarks.h" +#include "bookmarks.moc" + + +OwnBookMarks::OwnBookMarks(KMainWindow *parent) +{ + +} + + +virtual void OwnBookMarks::openBookmark (const KBookmark & , Qt::MouseButtons , Qt::KeyboardModifiers ) +{ +} + + +// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + +BookmarkMenu::BookmarkMenu(KMainWindow *parent) + : KMenu(parent) +{ + m_parent = parent; + + KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks + m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); + + m_owner = new OwnBookMarks(parent); + + m_ac = new KActionCollection( this ); + setActions(); + + m_menu = m_bookmarkMenu = new KBookmarkMenu( m_manager , m_owner, this, m_ac ); +} + + + void BookmarkMenu::setActions() +{ + m_ac->addAction( KStandardAction::addBookmark( m_parent, SLOT( slotAddBookmark() ) , this ) ); +} \ No newline at end of file diff --git a/src/bookmarks.h b/src/bookmarks.h new file mode 100644 index 00000000..4f527436 --- /dev/null +++ b/src/bookmarks.h @@ -0,0 +1,55 @@ +/* ============================================================ + * + * This file is a part of the reKonq project + * + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef BOOKMARKS_H +#define BOOKMARKS_H + +#include +#include +#include + + +class OwnBookMarks : public KBookMarkOwner +{ +Q_OBJECT +public: + OwnBookMarks(KMainWindow *parent); + + virtual void openBookmark (const KBookmark & , Qt::MouseButtons , Qt::KeyboardModifiers ); +}; + + +class BookmarkMenu : public KMenu +{ +Q_OBJECT +public: + BookmarkMenu(KMainWindow *parent); + +private: + void setActions(); + + KBookmarkManager *m_manager; + OwnBookMarks *m_owner; + KActionCollection *m_ac; + KBookmarkMenu *m_menu; + KMainWindow *m_parent; +}; + +#endif + diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 0bf8b0ef..5b91fdb0 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -342,13 +342,14 @@ void BrowserMainWindow::setupMenu() KMenu* bookmarksMenu = new KMenu( i18n("&Bookmarks"), this ); - menuBar()->addMenu( bookmarksMenu ); - - KBookmarkManager *mgr = KBookmarkManager::managerForFile( "~/.kde/share/apps/konqueror/bookmarks.xml" , "konqueror" ); + KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); + KBookmarkManager *mgr = KBookmarkManager::managerForExternalFile( bookfile.path() ); //FIXME hardcoded path KActionCollection * ac = new KActionCollection( this ); ac->addAction( "Add Bookmark" , KStandardAction::addBookmark( this, SLOT( slotAddBookmark() ) , this ) ); m_bookmarkMenu = new KBookmarkMenu( mgr , 0 , bookmarksMenu , ac ); + menuBar()->addMenu( bookmarksMenu ); + // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- m_windowMenu = (KMenu *) menuBar()->addMenu( i18n("&Window") ); -- cgit v1.2.1 From 15ecefe10101dd068c4e075fca23ba64519bedb1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 2 Dec 2008 16:22:28 +0100 Subject: New Bookmarks menu, sharing bkmrs with Konqueror (And that's reKonq 1st feature!!) --- src/CMakeLists.txt | 1 + src/bookmarks.cpp | 41 +++++++++++++++++++++++++------------- src/bookmarks.h | 28 ++++++++++++++++++-------- src/browsermainwindow.cpp | 19 +++++++++--------- src/browsermainwindow.h | 7 ++----- src/tabwidget.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++ src/webview.h | 10 +++++----- 7 files changed, 115 insertions(+), 41 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bb01a78e..1e2a3866 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ SET( rekonq_SRCS edittableview.cpp edittreeview.cpp history.cpp + bookmarks.cpp modelmenu.cpp networkaccessmanager.cpp urlbar.cpp diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 29c175e8..6f9c3beb 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -17,42 +17,55 @@  *  * ============================================================ */ +// Local Includes #include "bookmarks.h" #include "bookmarks.moc" +#include "browsermainwindow.h" +#include "webview.h" + +// KDE Includes +#include OwnBookMarks::OwnBookMarks(KMainWindow *parent) + : QObject(parent) + , KBookmarkOwner() +{ + m_parent = qobject_cast( parent ); + connect( this, SIGNAL( openUrl( const QUrl &) ) , parent , SLOT( loadUrl( const QUrl & ) ) ); +} + + +void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons , Qt::KeyboardModifiers ) { + emit openUrl( (QUrl)b.url() ); +} +QString OwnBookMarks::currentUrl() const +{ + QUrl url = m_parent->currentTab()->url(); + return url.path(); } -virtual void OwnBookMarks::openBookmark (const KBookmark & , Qt::MouseButtons , Qt::KeyboardModifiers ) +QString OwnBookMarks::currentTitle() const { + QString title = m_parent->windowTitle(); + return title.remove( " - reKonq" ); } // ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -BookmarkMenu::BookmarkMenu(KMainWindow *parent) +BookmarksMenu::BookmarksMenu(KMainWindow *parent) : KMenu(parent) + , m_owner( new OwnBookMarks( parent ) ) { - m_parent = parent; - KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); - m_owner = new OwnBookMarks(parent); - m_ac = new KActionCollection( this ); - setActions(); - m_menu = m_bookmarkMenu = new KBookmarkMenu( m_manager , m_owner, this, m_ac ); + m_menu = new KBookmarkMenu( m_manager , m_owner, this, m_ac ); } - - - void BookmarkMenu::setActions() -{ - m_ac->addAction( KStandardAction::addBookmark( m_parent, SLOT( slotAddBookmark() ) , this ) ); -} \ No newline at end of file diff --git a/src/bookmarks.h b/src/bookmarks.h index 4f527436..80362e1c 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -20,36 +20,48 @@ #ifndef BOOKMARKS_H #define BOOKMARKS_H +// KDE Includes #include #include #include +#include +#include -class OwnBookMarks : public KBookMarkOwner +class BrowserMainWindow; + +class OwnBookMarks : public QObject , public KBookmarkOwner { Q_OBJECT public: - OwnBookMarks(KMainWindow *parent); + OwnBookMarks(KMainWindow * ); virtual void openBookmark (const KBookmark & , Qt::MouseButtons , Qt::KeyboardModifiers ); + + // KBookmarkOwner interface: + virtual QString currentUrl() const; + virtual QString currentTitle() const; + +signals: + void openUrl(const QUrl &); // FIXME pass all to KUrl!! + +private: + BrowserMainWindow *m_parent; }; -class BookmarkMenu : public KMenu +class BookmarksMenu : public KMenu { Q_OBJECT public: - BookmarkMenu(KMainWindow *parent); + BookmarksMenu(KMainWindow * parent); private: - void setActions(); - KBookmarkManager *m_manager; OwnBookMarks *m_owner; KActionCollection *m_ac; KBookmarkMenu *m_menu; - KMainWindow *m_parent; }; -#endif +#endif diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 5b91fdb0..57c6e4bf 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -27,7 +27,7 @@ #include "history.h" #include "settings.h" #include "tabwidget.h" -// #include "toolbarsearch.h" +#include "bookmarks.h" #include "webview.h" // UI Includes @@ -67,7 +67,6 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) , m_historyForward(0) , m_stop(0) , m_reload(0) - , m_bookmarkMenu(0) { // delete widget accepting close event setAttribute(Qt::WA_DeleteOnClose, true); @@ -340,13 +339,15 @@ void BrowserMainWindow::setupMenu() // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- - KMenu* bookmarksMenu = new KMenu( i18n("&Bookmarks"), this ); - - KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); - KBookmarkManager *mgr = KBookmarkManager::managerForExternalFile( bookfile.path() ); //FIXME hardcoded path - KActionCollection * ac = new KActionCollection( this ); - ac->addAction( "Add Bookmark" , KStandardAction::addBookmark( this, SLOT( slotAddBookmark() ) , this ) ); - m_bookmarkMenu = new KBookmarkMenu( mgr , 0 , bookmarksMenu , ac ); + BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); + bookmarksMenu->setTitle( i18n("&Bookmarks") ); +// m_bookmarksMenu = new KMenu( i18n("&Bookmarks"), this ); +// +// KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); +// KBookmarkManager *mgr = KBookmarkManager::managerForExternalFile( bookfile.path() ); //FIXME hardcoded path +// KActionCollection * ac = new KActionCollection( this ); +// ac->addAction( "Add Bookmark" , KStandardAction::addBookmark( this, SLOT( slotAddBookmark() ) , this ) ); +// m_bookmarkMenu = new KBookmarkMenu( mgr , 0 , bookmarksMenu , ac ); menuBar()->addMenu( bookmarksMenu ); diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 5ead8dda..3c459d18 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -32,7 +32,6 @@ #include #include #include -#include // Qt Includes #include @@ -41,7 +40,6 @@ class AutoSaver; class QWebFrame; class TabWidget; -// class ToolbarSearch; class WebView; /*! @@ -49,7 +47,8 @@ class WebView; Handles the tab widget and all the actions */ -class BrowserMainWindow : public KMainWindow { +class BrowserMainWindow : public KMainWindow +{ Q_OBJECT public: @@ -150,8 +149,6 @@ private: FindBar *m_findBar; QString m_lastSearch; - - KBookmarkMenu* m_bookmarkMenu; }; #endif // BROWSERMAINWINDOW_H diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 9ce8aa59..efa77a95 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -179,8 +179,10 @@ void TabBar::reloadTab() } } + // -------------------------------------------------------------------------------------------------------------------------------------------------------- + TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent) , m_recentlyClosedTabsAction(0) @@ -258,6 +260,7 @@ TabWidget::TabWidget(QWidget *parent) m_lineEdits = new QStackedWidget(this); } + void TabWidget::clear() { // clear the recently closed tabs @@ -269,6 +272,7 @@ void TabWidget::clear() } } + void TabWidget::moveTab(int fromIndex, int toIndex) { disconnect(this, SIGNAL(currentChanged(int)), @@ -285,6 +289,7 @@ void TabWidget::moveTab(int fromIndex, int toIndex) setCurrentIndex(toIndex); } + // When index is -1 index chooses the current tab void TabWidget::reloadTab(int index) { @@ -299,6 +304,7 @@ void TabWidget::reloadTab(int index) } + void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction) { if (!action) @@ -306,6 +312,7 @@ void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction) m_actions.append(new WebActionMapper(action, webAction, this)); } + void TabWidget::currentChanged(int index) { WebView *webView = this->webView(index); @@ -347,46 +354,55 @@ void TabWidget::currentChanged(int index) webView->setFocus(); } + KAction *TabWidget::newTabAction() const { return m_newTabAction; } + KAction *TabWidget::closeTabAction() const { return m_closeTabAction; } + KAction *TabWidget::recentlyClosedTabsAction() const { return m_recentlyClosedTabsAction; } + KAction *TabWidget::nextTabAction() const { return m_nextTabAction; } + KAction *TabWidget::previousTabAction() const { return m_previousTabAction; } + QWidget *TabWidget::lineEditStack() const { return m_lineEdits; } + KLineEdit *TabWidget::currentLineEdit() const { return lineEdit(m_lineEdits->currentIndex()); } + WebView *TabWidget::currentWebView() const { return webView(currentIndex()); } + KLineEdit *TabWidget::lineEdit(int index) const { UrlBar *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); @@ -395,6 +411,7 @@ KLineEdit *TabWidget::lineEdit(int index) const return 0; } + WebView *TabWidget::webView(int index) const { QWidget *widget = this->widget(index); @@ -418,12 +435,14 @@ WebView *TabWidget::webView(int index) const return 0; } + int TabWidget::webViewIndex(WebView *webView) const { int index = indexOf(webView); return index; } + WebView *TabWidget::newTab(bool makeCurrent) { // line edit @@ -491,6 +510,7 @@ WebView *TabWidget::newTab(bool makeCurrent) return webView; } + void TabWidget::reloadAllTabs() { for (int i = 0; i < count(); ++i) @@ -503,6 +523,7 @@ void TabWidget::reloadAllTabs() } } + void TabWidget::lineEditReturnPressed() { if (KLineEdit *lineEdit = qobject_cast(sender())) @@ -513,6 +534,7 @@ void TabWidget::lineEditReturnPressed() } } + void TabWidget::windowCloseRequested() { WebPage *webPage = qobject_cast(sender()); @@ -527,6 +549,7 @@ void TabWidget::windowCloseRequested() } } + void TabWidget::closeOtherTabs(int index) { if (-1 == index) @@ -537,6 +560,7 @@ void TabWidget::closeOtherTabs(int index) closeTab(i); } + // When index is -1 index chooses the current tab void TabWidget::cloneTab(int index) { @@ -548,6 +572,7 @@ void TabWidget::cloneTab(int index) tab->setUrl(webView(index)->url()); } + // When index is -1 index chooses the current tab void TabWidget::closeTab(int index) { @@ -591,6 +616,7 @@ void TabWidget::closeTab(int index) emit lastTabClosed(); } + void TabWidget::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); @@ -601,6 +627,7 @@ void TabWidget::webViewLoadStarted() } } + void TabWidget::webViewIconChanged() { WebView *webView = qobject_cast(sender()); @@ -612,6 +639,7 @@ void TabWidget::webViewIconChanged() } } + void TabWidget::webViewTitleChanged(const QString &title) { WebView *webView = qobject_cast(sender()); @@ -624,6 +652,7 @@ void TabWidget::webViewTitleChanged(const QString &title) BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); } + void TabWidget::webViewUrlChanged(const QUrl &url) { WebView *webView = qobject_cast(sender()); @@ -634,6 +663,7 @@ void TabWidget::webViewUrlChanged(const QUrl &url) emit tabsChanged(); } + void TabWidget::aboutToShowRecentTabsMenu() { m_recentlyClosedTabsMenu->clear(); @@ -648,12 +678,14 @@ void TabWidget::aboutToShowRecentTabsMenu() } } + void TabWidget::aboutToShowRecentTriggeredAction(QAction *action) { QUrl url = action->data().toUrl(); loadUrlInCurrentTab(url); } + void TabWidget::mouseDoubleClickEvent(QMouseEvent *event) { if ( !childAt(event->pos()) @@ -666,6 +698,7 @@ void TabWidget::mouseDoubleClickEvent(QMouseEvent *event) QTabWidget::mouseDoubleClickEvent(event); } + void TabWidget::contextMenuEvent(QContextMenuEvent *event) { if (!childAt(event->pos())) { @@ -675,6 +708,7 @@ void TabWidget::contextMenuEvent(QContextMenuEvent *event) QTabWidget::contextMenuEvent(event); } + void TabWidget::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::MidButton && !childAt(event->pos()) @@ -690,6 +724,7 @@ void TabWidget::mouseReleaseEvent(QMouseEvent *event) } } + void TabWidget::loadUrlInCurrentTab(const QUrl &url) { WebView *webView = currentWebView(); @@ -700,6 +735,7 @@ void TabWidget::loadUrlInCurrentTab(const QUrl &url) } } + void TabWidget::nextTab() { int next = currentIndex() + 1; @@ -708,6 +744,7 @@ void TabWidget::nextTab() setCurrentIndex(next); } + void TabWidget::previousTab() { int next = currentIndex() - 1; @@ -716,8 +753,10 @@ void TabWidget::previousTab() setCurrentIndex(next); } + static const qint32 TabWidgetMagic = 0xaa; + QByteArray TabWidget::saveState() const { int version = 1; @@ -744,6 +783,7 @@ QByteArray TabWidget::saveState() const return data; } + bool TabWidget::restoreState(const QByteArray &state) { int version = 1; @@ -776,6 +816,10 @@ bool TabWidget::restoreState(const QByteArray &state) return true; } + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) : QObject(parent) , m_currentParent(0) @@ -789,16 +833,19 @@ WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, Q root->setEnabled(false); } + void WebActionMapper::rootDestroyed() { m_root = 0; } + void WebActionMapper::currentDestroyed() { updateCurrent(0); } + void WebActionMapper::addChild(KAction *action) { if (!action) @@ -811,6 +858,7 @@ QWebPage::WebAction WebActionMapper::webAction() const return m_webAction; } + void WebActionMapper::rootTriggered() { if (m_currentParent) @@ -820,6 +868,7 @@ void WebActionMapper::rootTriggered() } } + void WebActionMapper::childChanged() { if (KAction *source = qobject_cast(sender())) @@ -834,6 +883,7 @@ void WebActionMapper::childChanged() } } + void WebActionMapper::updateCurrent(QWebPage *currentParent) { if (m_currentParent) diff --git a/src/webview.h b/src/webview.h index ccd44a6f..f81544a0 100644 --- a/src/webview.h +++ b/src/webview.h @@ -32,7 +32,9 @@ class QSslError; QT_END_NAMESPACE class BrowserMainWindow; -class WebPage : public QWebPage { + +class WebPage : public QWebPage +{ Q_OBJECT signals: @@ -45,9 +47,6 @@ public: protected: bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); QWebPage *createWindow(QWebPage::WebWindowType type); -// #if !defined(QT_NO_UITOOLS) -// QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); -// #endif private slots: void handleUnsupportedContent(QNetworkReply *reply); @@ -62,7 +61,8 @@ private: QUrl m_loadingUrl; }; -class WebView : public QWebView { +class WebView : public QWebView +{ Q_OBJECT public: -- cgit v1.2.1 From b9f8ccd9099fa48406203ad5c5389266b3318d88 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Dec 2008 00:27:23 +0100 Subject: QUrl --> KUrl! --- TODO | 4 +- src/bookmarks.cpp | 4 +- src/bookmarks.h | 3 +- src/browserapplication.cpp | 27 ++++++---- src/browserapplication.h | 8 +-- src/browsermainwindow.cpp | 128 ++++++++++++++++++++++++++++++--------------- src/browsermainwindow.h | 9 ++-- src/history.cpp | 10 ++-- src/history.h | 27 +++++++--- src/searchbar.cpp | 2 +- src/searchbar.h | 4 +- src/settings.cpp | 25 ++++++--- src/tabwidget.cpp | 28 ++++++---- src/tabwidget.h | 12 +++-- src/urlbar.cpp | 33 +----------- src/urlbar.h | 4 -- src/webview.cpp | 112 ++++++++++++++++++++++----------------- src/webview.h | 16 ++++-- 18 files changed, 269 insertions(+), 187 deletions(-) diff --git a/TODO b/TODO index 78f0f8a8..3aae668b 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,8 @@ Road to 0.0.1 (first release) + ESC event findbar + let findbar work -- bookmarks (share konqueror's) -- some porting ++ bookmarks (share konqueror's) ++ some porting NEXT.. - better FULL SCREEN diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 6f9c3beb..e03bf3dc 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -32,13 +32,13 @@ OwnBookMarks::OwnBookMarks(KMainWindow *parent) , KBookmarkOwner() { m_parent = qobject_cast( parent ); - connect( this, SIGNAL( openUrl( const QUrl &) ) , parent , SLOT( loadUrl( const QUrl & ) ) ); + connect( this, SIGNAL( openUrl( const KUrl &) ) , parent , SLOT( loadUrl( const KUrl & ) ) ); } void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons , Qt::KeyboardModifiers ) { - emit openUrl( (QUrl)b.url() ); + emit openUrl( b.url() ); } QString OwnBookMarks::currentUrl() const diff --git a/src/bookmarks.h b/src/bookmarks.h index 80362e1c..950fc8a6 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -43,7 +44,7 @@ public: virtual QString currentTitle() const; signals: - void openUrl(const QUrl &); // FIXME pass all to KUrl!! + void openUrl(const KUrl &); private: BrowserMainWindow *m_parent; diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 3099dfc2..a79f28b2 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -19,6 +19,7 @@  * ============================================================ */ +// Local Includes #include "browserapplication.h" #include "browsermainwindow.h" @@ -29,9 +30,12 @@ #include "tabwidget.h" #include "webview.h" +// KDE Includes #include #include +#include +// Qt Includes #include #include #include @@ -259,18 +263,23 @@ void BrowserApplication::restoreLastSession() buffer.open(QIODevice::ReadOnly); int windowCount; stream >> windowCount; - for (int i = 0; i < windowCount; ++i) { + for (int i = 0; i < windowCount; ++i) + { QByteArray windowState; stream >> windowState; windows.append(windowState); } - for (int i = 0; i < windows.count(); ++i) { + for (int i = 0; i < windows.count(); ++i) + { BrowserMainWindow *newWindow = 0; if (m_mainWindows.count() == 1 && mainWindow()->tabWidget()->count() == 1 - && mainWindow()->currentTab()->url() == QUrl()) { + && mainWindow()->currentTab()->url() == QUrl()) + { newWindow = mainWindow(); - } else { + } + else + { newWindow = newMainWindow(); } newWindow->restoreState(windows.at(i)); @@ -295,9 +304,9 @@ void BrowserApplication::installTranslator(const QString &name) -void BrowserApplication::openUrl(const QUrl &url) +void BrowserApplication::openUrl(const KUrl &url) { - mainWindow()->loadPage(url.toString()); + mainWindow()->loadPage( url.url() ); } @@ -311,8 +320,6 @@ BrowserMainWindow *BrowserApplication::newMainWindow() } - - BrowserMainWindow *BrowserApplication::mainWindow() { clean(); @@ -322,8 +329,6 @@ BrowserMainWindow *BrowserApplication::mainWindow() } - - void BrowserApplication::newLocalSocketConnection() { QLocalSocket *socket = m_localServer->nextPendingConnection(); @@ -392,7 +397,7 @@ HistoryManager *BrowserApplication::historyManager() -KIcon BrowserApplication::icon(const QUrl &url) const +KIcon BrowserApplication::icon(const KUrl &url) const { KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); if (!icon.isNull()) diff --git a/src/browserapplication.h b/src/browserapplication.h index 43d374d3..cee28895 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -22,11 +22,13 @@ #ifndef BROWSERAPPLICATION_H #define BROWSERAPPLICATION_H +// KDE Includes #include #include #include +#include -#include +// Qt Includes #include QT_BEGIN_NAMESPACE @@ -52,7 +54,7 @@ public: bool isTheOnlyBrowser() const; BrowserMainWindow *mainWindow(); QList mainWindows(); - KIcon icon(const QUrl &url) const; + KIcon icon(const KUrl &url) const; void saveSession(); bool canRestoreSession() const; @@ -68,7 +70,7 @@ public slots: private slots: void postLaunch(); - void openUrl(const QUrl &url); + void openUrl(const KUrl &url); void newLocalSocketConnection(); private: diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 57c6e4bf..ada00b5c 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -308,7 +308,7 @@ void BrowserMainWindow::setupMenu() // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- HistoryMenu *historyMenu = new HistoryMenu(this); - connect(historyMenu, SIGNAL(openUrl(const QUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const QUrl&))); + connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle( i18n("Hi&story") ); menuBar()->addMenu(historyMenu); @@ -400,7 +400,7 @@ void BrowserMainWindow::setupToolBar() m_searchBar = new SearchBar(m_navigationBar); m_navigationBar->addWidget(m_searchBar); - connect(m_searchBar, SIGNAL(search(const QUrl&)), this, SLOT(loadUrl(const QUrl&))); + connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); // UI settings m_navigationBar->setIconDimensions(16); @@ -443,52 +443,66 @@ void BrowserMainWindow::slotViewStatusbar() -QUrl BrowserMainWindow::guessUrlFromString(const QString &string) +KUrl BrowserMainWindow::guessUrlFromString(const QString &string) { QString urlStr = string.trimmed(); QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); // Check if it looks like a qualified URL. Try parsing it and see. bool hasSchema = test.exactMatch(urlStr); - if (hasSchema) { - QUrl url(urlStr, QUrl::TolerantMode); - if (url.isValid()) + if (hasSchema) + { + QUrl qurl(urlStr, QUrl::TolerantMode); + KUrl url(qurl); + if ( url.isValid() ) + { return url; + } } // Might be a file. - if (QFile::exists(urlStr)) { + if (QFile::exists(urlStr)) + { QFileInfo info(urlStr); - return QUrl::fromLocalFile(info.absoluteFilePath()); + return KUrl::fromPath( info.absoluteFilePath() ); } // Might be a shorturl - try to detect the schema. - if (!hasSchema) { + if (!hasSchema) + { int dotIndex = urlStr.indexOf(QLatin1Char('.')); - if (dotIndex != -1) { + if (dotIndex != -1) + { QString prefix = urlStr.left(dotIndex).toLower(); QString schema = (prefix == QLatin1String("ftp")) ? prefix : QLatin1String("http"); - QUrl url(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode); - if (url.isValid()) + QUrl qurl(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode); + KUrl url(qurl); + if ( url.isValid() ) + { return url; + } } } // Fall back to QUrl's own tolerant parser. - QUrl url = QUrl(string, QUrl::TolerantMode); + QUrl qurl = QUrl(string, QUrl::TolerantMode); + KUrl url(qurl); // finally for cases where the user just types in a hostname add http - if (url.scheme().isEmpty()) - url = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode); + if ( qurl.scheme().isEmpty() ) + { + qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode); + url = KUrl(qurl); + } return url; } -void BrowserMainWindow::loadUrl(const QUrl &url) +void BrowserMainWindow::loadUrl(const KUrl &url) { - loadPage(url.toString()); + loadPage( url.url() ); } @@ -574,8 +588,7 @@ void BrowserMainWindow::slotFilePrintPreview() if (!currentTab()) return; QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this); - connect(dialog, SIGNAL(paintRequested(QPrinter *)), - currentTab(), SLOT(print(QPrinter *))); + connect(dialog, SIGNAL(paintRequested(QPrinter *)), currentTab(), SLOT(print(QPrinter *))); dialog->exec(); } @@ -595,7 +608,7 @@ void BrowserMainWindow::printRequested(QWebFrame *frame) QPrinter printer; QPrintDialog *dialog = new QPrintDialog(&printer, this); dialog->setWindowTitle( i18n("Print Document") ); - if (dialog->exec() != QDialog::Accepted) + if (dialog->exec() != QDialog::Accepted ) return; frame->print(&printer); } @@ -606,7 +619,8 @@ void BrowserMainWindow::slotPrivateBrowsing() { QWebSettings *settings = QWebSettings::globalSettings(); bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); - if (!pb) { + if (!pb) + { QString title = i18n("Are you sure you want to turn on private browsing?"); QString text = "" + title + i18n("

When private browsing in turned on," " webpages are not added to the history," @@ -620,14 +634,18 @@ void BrowserMainWindow::slotPrivateBrowsing() QMessageBox::StandardButton button = QMessageBox::question(this, QString(), text, QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); - if (button == QMessageBox::Ok) { + if (button == QMessageBox::Ok) + { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); } - } else { + } + else + { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); QList windows = BrowserApplication::instance()->mainWindows(); - for (int i = 0; i < windows.count(); ++i) { + for (int i = 0; i < windows.count(); ++i) + { BrowserMainWindow *window = windows.at(i); window->m_lastSearch = QString::null; window->tabWidget()->clear(); @@ -639,13 +657,15 @@ void BrowserMainWindow::slotPrivateBrowsing() void BrowserMainWindow::closeEvent(QCloseEvent *event) { - if (m_tabWidget->count() > 1) { + if (m_tabWidget->count() > 1) + { int ret = QMessageBox::warning(this, QString(), i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , QMessageBox::Yes | QMessageBox::No, QMessageBox::No); - if (ret == QMessageBox::No) { + if (ret == QMessageBox::No) + { event->ignore(); return; } @@ -721,14 +741,27 @@ void BrowserMainWindow::slotViewTextSmaller() void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) { - if (makeFullScreen) { + if (makeFullScreen) + { showFullScreen(); - } else { - if (isMinimized()) + } + else + { + if ( isMinimized() ) + { showMinimized(); - else if (isMaximized()) - showMaximized(); - else showNormal(); + } + else + { + if (isMaximized()) + { + showMaximized(); + } + else + { + showNormal(); + } + } } } @@ -773,12 +806,14 @@ void BrowserMainWindow::slotWebSearch() void BrowserMainWindow::slotToggleInspector(bool enable) { QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); - if (enable) { + if (enable) + { int result = QMessageBox::question(this, i18n("Web Inspector"), i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" "Do you want to reload all pages?"), QMessageBox::Yes | QMessageBox::No); - if (result == QMessageBox::Yes) { + if (result == QMessageBox::Yes) + { m_tabWidget->reloadAllTabs(); } } @@ -854,7 +889,8 @@ void BrowserMainWindow::slotAboutToShowBackMenu() return; QWebHistory *history = currentTab()->history(); int historyCount = history->count(); - for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { + for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) + { QWebHistoryItem item = history->backItems(history->count()).at(i); KAction *action = new KAction(this); action->setData(-1*(historyCount-i-1)); @@ -877,7 +913,8 @@ void BrowserMainWindow::slotAboutToShowWindowMenu() m_windowMenu->addSeparator(); QList windows = BrowserApplication::instance()->mainWindows(); - for (int i = 0; i < windows.count(); ++i) { + for (int i = 0; i < windows.count(); ++i) + { BrowserMainWindow *window = windows.at(i); QAction *action = m_windowMenu->addAction(window->windowTitle(), this, SLOT(slotShowWindow())); action->setData(i); @@ -892,9 +929,11 @@ void BrowserMainWindow::slotAboutToShowWindowMenu() void BrowserMainWindow::slotShowWindow() { - if (KAction *action = qobject_cast(sender())) { + if (KAction *action = qobject_cast(sender())) + { QVariant v = action->data(); - if (v.canConvert()) { + if (v.canConvert()) + { int offset = qvariant_cast(v); QList windows = BrowserApplication::instance()->mainWindows(); windows.at(offset)->activateWindow(); @@ -911,10 +950,17 @@ void BrowserMainWindow::slotOpenActionUrl(QAction *action) int offset = action->data().toInt(); QWebHistory *history = currentTab()->history(); if (offset < 0) + { history->goToItem(history->backItems(-1*offset).first()); // back - else if (offset > 0) - history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward - } + } + else + { + if (offset > 0) + { + history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward + } + } +} void BrowserMainWindow::slotOpenPrevious() diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 3c459d18..237f872d 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -27,14 +27,15 @@ #include "searchbar.h" // KDE Includes +#include #include #include #include #include #include -// Qt Includes -#include +// // Qt Includes +// #include class AutoSaver; @@ -57,7 +58,7 @@ public: QSize sizeHint() const; public: - static QUrl guessUrlFromString(const QString &url); + static KUrl guessUrlFromString(const QString &url); TabWidget *tabWidget() const; WebView *currentTab() const; QByteArray saveState(bool withTabs = true) const; @@ -80,7 +81,7 @@ private slots: void slotUpdateStatusbar(const QString &string); void slotUpdateWindowTitle(const QString &title = QString()); - void loadUrl(const QUrl &url); + void loadUrl(const KUrl &url); void slotPreferences(); void slotFileNew(); diff --git a/src/history.cpp b/src/history.cpp index cb6e80b0..43714166 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -181,10 +181,12 @@ void HistoryManager::addHistoryItem(const HistoryItem &item) -void HistoryManager::updateHistoryItem(const QUrl &url, const QString &title) +void HistoryManager::updateHistoryItem(const KUrl &url, const QString &title) { - for (int i = 0; i < m_history.count(); ++i) { - if (url == m_history.at(i).url) { + for (int i = 0; i < m_history.count(); ++i) + { + if (url == m_history.at(i).url) + { m_history[i].title = title; m_saveTimer->changeOccurred(); if (m_lastSavedUrl.isEmpty()) @@ -654,7 +656,7 @@ void HistoryMenu::postPopulated() void HistoryMenu::showHistoryDialog() { HistoryDialog *dialog = new HistoryDialog(this); - connect(dialog, SIGNAL(openUrl(const QUrl&)), this, SIGNAL(openUrl(const QUrl&))); + connect(dialog, SIGNAL(openUrl(const KUrl&)), this, SIGNAL(openUrl(const KUrl&))); dialog->show(); } diff --git a/src/history.h b/src/history.h index 97d7f34e..41763b69 100644 --- a/src/history.h +++ b/src/history.h @@ -25,18 +25,18 @@ // Local Includes #include "modelmenu.h" +// KDE Includes +#include +#include + // Qt Includes #include #include #include #include -#include #include #include -// KDE Includes -#include - class HistoryItem { @@ -61,13 +61,15 @@ public: +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + class AutoSaver; class HistoryModel; class HistoryFilterModel; class HistoryTreeModel; -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + class HistoryManager : public QWebHistoryInterface { Q_OBJECT @@ -86,7 +88,7 @@ public: bool historyContains(const QString &url) const; void addHistoryEntry(const QString &url); - void updateHistoryItem(const QUrl &url, const QString &title); + void updateHistoryItem(const KUrl &url, const QString &title); int historyLimit() const; void setHistoryLimit(int limit); @@ -126,6 +128,8 @@ private: // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + + class HistoryModel : public QAbstractTableModel { Q_OBJECT @@ -234,7 +238,7 @@ class HistoryMenu : public ModelMenu Q_OBJECT signals: - void openUrl(const QUrl &url); + void openUrl(const KUrl &url); public: HistoryMenu(QWidget *parent = 0); @@ -278,6 +282,8 @@ private slots: }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // proxy model for the history model that converts the list // into a tree, one top level node per day. // Used in the HistoryDialog. @@ -312,6 +318,8 @@ private: }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // A modified QSortFilterProxyModel that always accepts the root nodes in the tree // so filtering is only done on the children. // Used in the HistoryDialog @@ -326,6 +334,9 @@ protected: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; }; + +// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + #include "ui_history.h" class HistoryDialog : public QDialog, public Ui_HistoryDialog @@ -333,7 +344,7 @@ class HistoryDialog : public QDialog, public Ui_HistoryDialog Q_OBJECT signals: - void openUrl(const QUrl &url); + void openUrl(const KUrl &url); public: HistoryDialog(QWidget *parent = 0, HistoryManager *history = 0); diff --git a/src/searchbar.cpp b/src/searchbar.cpp index deb8d631..a2f1217f 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -46,7 +46,7 @@ void SearchBar::searchNow() { QString searchText = m_lineEdit->text(); - QUrl url(QLatin1String("http://www.google.com/search")); + KUrl url(QLatin1String("http://www.google.com/search")); url.addQueryItem(QLatin1String("q"), searchText); url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); diff --git a/src/searchbar.h b/src/searchbar.h index 40235891..92f20f8e 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -23,10 +23,10 @@ // KDE Includes #include +#include // Qt Includes #include -#include class SearchBar : public QWidget { @@ -45,7 +45,7 @@ private: KLineEdit *m_lineEdit; signals: - void search(const QUrl &url); + void search(const KUrl &url); }; diff --git a/src/settings.cpp b/src/settings.cpp index d23e7def..2a440c19 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -23,8 +23,6 @@ #include "settings.h" #include "settings.moc" -// #include "ui_settings.h" - #include "browserapplication.h" #include "browsermainwindow.h" #include "cookiejar.h" @@ -68,6 +66,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) loadFromSettings(); } + void SettingsDialog::loadDefaults() { QWebSettings *defaultSettings = QWebSettings::globalSettings(); @@ -87,6 +86,7 @@ void SettingsDialog::loadDefaults() enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); } + void SettingsDialog::loadFromSettings() { KConfig config("rekonqrc"); @@ -136,7 +136,8 @@ void SettingsDialog::loadFromSettings() CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? CookieJar::AcceptOnlyFromSitesNavigatedTo : static_cast(acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) ); - switch(acceptCookies) { + switch(acceptCookies) + { case CookieJar::AcceptAlways: acceptCombo->setCurrentIndex(0); break; @@ -177,6 +178,7 @@ void SettingsDialog::loadFromSettings() } + void SettingsDialog::saveToSettings() { KConfig config("rekonqrc"); @@ -188,7 +190,8 @@ void SettingsDialog::saveToSettings() int historyExpire = expireHistory->currentIndex(); int idx = -1; - switch (historyExpire) { + switch (historyExpire) + { case 0: idx = 1; break; case 1: idx = 7; break; case 2: idx = 14; break; @@ -207,7 +210,8 @@ void SettingsDialog::saveToSettings() group3.writeEntry(QString("enablePlugins"), enablePlugins->isChecked() ); CookieJar::KeepPolicy keepCookies; - switch(acceptCombo->currentIndex()) { + switch(acceptCombo->currentIndex()) + { default: case 0: keepCookies = CookieJar::KeepUntilExpire; @@ -224,7 +228,8 @@ void SettingsDialog::saveToSettings() group3.writeEntry(QString("acceptCookies"), QString(acceptPolicyEnum.valueToKey(keepCookies) ) ); CookieJar::KeepPolicy keepPolicy; - switch(keepUntilCombo->currentIndex()) { + switch(keepUntilCombo->currentIndex()) + { default: case 0: keepPolicy = CookieJar::KeepUntilExpire; @@ -265,12 +270,14 @@ void SettingsDialog::showCookies() dialog->exec(); } + void SettingsDialog::showExceptions() { CookiesExceptionsDialog *dialog = new CookiesExceptionsDialog(BrowserApplication::cookieJar(), this); dialog->exec(); } + void SettingsDialog::chooseFont() { QFont myFont; @@ -282,6 +289,7 @@ void SettingsDialog::chooseFont() } } + void SettingsDialog::chooseFixedFont() { @@ -294,12 +302,15 @@ void SettingsDialog::chooseFixedFont() } } + void SettingsDialog::setHomeToCurrentPage() { BrowserMainWindow *mw = static_cast(parent()); WebView *webView = mw->currentTab(); if (webView) - homeLineEdit->setText(webView->url().toString()); + { + homeLineEdit->setText( webView->url().prettyUrl() ); + } } diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index efa77a95..32d43d65 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -52,6 +52,7 @@ TabBar::TabBar(QWidget *parent) } } + void TabBar::selectTabAction() { if (QShortcut *shortCut = qobject_cast(sender())) @@ -63,6 +64,7 @@ void TabBar::selectTabAction() } } + void TabBar::contextMenuRequested(const QPoint &position) { QMenu menu; @@ -94,14 +96,17 @@ void TabBar::contextMenuRequested(const QPoint &position) menu.exec(QCursor::pos()); } + void TabBar::cloneTab() { - if (QAction *action = qobject_cast(sender())) { + if (QAction *action = qobject_cast(sender())) + { int index = action->data().toInt(); emit cloneTab(index); } } + void TabBar::closeTab() { if (QAction *action = qobject_cast(sender())) @@ -111,6 +116,7 @@ void TabBar::closeTab() } } + void TabBar::closeOtherTabs() { if (QAction *action = qobject_cast(sender())) @@ -120,6 +126,7 @@ void TabBar::closeOtherTabs() } } + void TabBar::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) @@ -127,6 +134,7 @@ void TabBar::mousePressEvent(QMouseEvent *event) QTabBar::mousePressEvent(event); } + void TabBar::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() == Qt::LeftButton && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) @@ -146,6 +154,7 @@ void TabBar::mouseMoveEvent(QMouseEvent *event) QTabBar::mouseMoveEvent(event); } + void TabBar::dragEnterEvent(QDragEnterEvent *event) { const QMimeData *mimeData = event->mimeData(); @@ -158,6 +167,7 @@ void TabBar::dragEnterEvent(QDragEnterEvent *event) QTabBar::dragEnterEvent(event); } + void TabBar::dropEvent(QDropEvent *event) { int fromIndex = tabAt(m_dragStartPos); @@ -319,7 +329,7 @@ void TabWidget::currentChanged(int index) if (!webView) return; - Q_ASSERT(m_lineEdits->count() == count()); + Q_ASSERT( m_lineEdits->count() == count() ); WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); if (oldWebView) @@ -493,7 +503,7 @@ WebView *TabWidget::newTab(bool makeCurrent) connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); - addTab(webView, i18n("(Untitled)")); + addTab(webView, i18n("(Untitled)") ); if (makeCurrent) setCurrentWidget(webView); @@ -569,7 +579,7 @@ void TabWidget::cloneTab(int index) if (index < 0 || index >= count()) return; WebView *tab = newTab(false); - tab->setUrl(webView(index)->url()); + tab->setUrl( webView(index)->url() ); } @@ -673,7 +683,7 @@ void TabWidget::aboutToShowRecentTabsMenu() action->setData(m_recentlyClosedTabs.at(i)); QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); action->setIcon(icon); - action->setText(m_recentlyClosedTabs.at(i).toString()); + action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); m_recentlyClosedTabsMenu->addAction(action); } } @@ -681,7 +691,7 @@ void TabWidget::aboutToShowRecentTabsMenu() void TabWidget::aboutToShowRecentTriggeredAction(QAction *action) { - QUrl url = action->data().toUrl(); + KUrl url = action->data().toUrl(); loadUrlInCurrentTab(url); } @@ -715,7 +725,7 @@ void TabWidget::mouseReleaseEvent(QMouseEvent *event) // Remove the line below when QTabWidget does not have a one pixel frame && event->pos().y() < (tabBar()->y() + tabBar()->height())) { - QUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { WebView *webView = newTab(); @@ -725,7 +735,7 @@ void TabWidget::mouseReleaseEvent(QMouseEvent *event) } -void TabWidget::loadUrlInCurrentTab(const QUrl &url) +void TabWidget::loadUrlInCurrentTab(const KUrl &url) { WebView *webView = currentWebView(); if (webView) @@ -771,7 +781,7 @@ QByteArray TabWidget::saveState() const { if (WebView *tab = qobject_cast(widget(i))) { - tabs.append(tab->url().toString()); + tabs.append(tab->url().prettyUrl()); } else { diff --git a/src/tabwidget.h b/src/tabwidget.h index 8e6d16b4..5a48072f 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -108,12 +108,14 @@ private: // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -#include -#include - +// KDE Includes +#include #include #include +// Qt Includes +#include + QT_BEGIN_NAMESPACE class QCompleter; class QMenu; @@ -173,7 +175,7 @@ protected: void mouseReleaseEvent(QMouseEvent *event); public slots: - void loadUrlInCurrentTab(const QUrl &url); + void loadUrlInCurrentTab(const KUrl &url); WebView *newTab(bool makeCurrent = true); void cloneTab(int index = -1); void closeTab(int index = -1); @@ -204,7 +206,7 @@ private: KMenu *m_recentlyClosedTabsMenu; static const int m_recentlyClosedTabsSize = 10; - QList m_recentlyClosedTabs; + QList m_recentlyClosedTabs; QList m_actions; QCompleter *m_lineEditCompleter; diff --git a/src/urlbar.cpp b/src/urlbar.cpp index cde55cb3..1ee02dc3 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -54,7 +54,7 @@ UrlBar::UrlBar(QWidget *parent) UrlBar::~UrlBar() { -// delete m_webView; + delete m_webView; delete m_iconLabel; delete m_lineEdit; } @@ -87,7 +87,7 @@ void UrlBar::webViewUrlChanged(const QUrl &url) void UrlBar::webViewIconChanged() { - QUrl url = (m_webView) ? m_webView->url() : QUrl(); + KUrl url = (m_webView) ? m_webView->url() : KUrl(); QIcon icon = BrowserApplication::instance()->icon(url); QPixmap pixmap(icon.pixmap(16, 16)); m_iconLabel->setPixmap(pixmap); @@ -104,32 +104,3 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const gradient.setColorAt(1, m_defaultBaseColor); return gradient; } - -// FIXME -// void UrlBar::paintEvent(QPaintEvent *event) -// { -// QPalette p = palette(); -// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) { -// QColor lightYellow(248, 248, 210); -// p.setBrush(QPalette::Base, generateGradient(lightYellow)); -// } else { -// p.setBrush(QPalette::Base, m_defaultBaseColor); -// } -// setPalette(p); -// -// QPainter painter(this); -// QStyleOptionFrameV2 panel; -// // initStyleOption(&panel); -// QRect backgroundRect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this); -// if (m_webView && !hasFocus()) -// { -// int progress = m_webView->progress(); -// QColor loadingColor = QColor(116, 192, 250); -// painter.setBrush(generateGradient(loadingColor)); -// painter.setPen(Qt::transparent); -// int mid = backgroundRect.width() / 100 * progress; -// QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); -// painter.drawRect(progressRect); -// } -// } - diff --git a/src/urlbar.h b/src/urlbar.h index 72b64654..5d766a92 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -43,10 +43,6 @@ public: KLineEdit *lineEdit(); void setWebView(WebView *webView); -// FIXME needed to color urlbar while loading urls -// protected: -// void paintEvent(QPaintEvent *event); - private slots: void webViewUrlChanged(const QUrl &url); void webViewIconChanged(); diff --git a/src/webview.cpp b/src/webview.cpp index 7cae61cf..2e97c486 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +//#include #include @@ -45,11 +45,11 @@ WebPage::WebPage(QObject *parent) , m_pressedButtons(Qt::NoButton) , m_openInNewTab(false) { - setNetworkAccessManager(BrowserApplication::networkAccessManager()); - connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), - this, SLOT(handleUnsupportedContent(QNetworkReply *))); + setNetworkAccessManager( BrowserApplication::networkAccessManager() ); + connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); } + BrowserMainWindow *WebPage::mainWindow() { QObject *w = this->parent(); @@ -61,24 +61,28 @@ BrowserMainWindow *WebPage::mainWindow() return BrowserApplication::instance()->mainWindow(); } + bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { // ctrl open in new tab // ctrl-shift open in new tab and select // ctrl-alt open in new window - if (type == QWebPage::NavigationTypeLinkClicked - && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton)) { + if ( type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton) ) + { bool newWindow = (m_keyboardModifiers & Qt::AltModifier); WebView *webView; - if (newWindow) { + if (newWindow) + { BrowserApplication::instance()->newMainWindow(); BrowserMainWindow *newMainWindow = BrowserApplication::instance()->mainWindow(); webView = newMainWindow->currentTab(); newMainWindow->raise(); newMainWindow->activateWindow(); webView->setFocus(); - } else { + } + else + { bool selectNewTab = (m_keyboardModifiers & Qt::ShiftModifier); webView = mainWindow()->tabWidget()->newTab(selectNewTab); } @@ -87,19 +91,22 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r m_pressedButtons = Qt::NoButton; return false; } - if (frame == mainFrame()) { + if ( frame == mainFrame() ) + { m_loadingUrl = request.url(); emit loadingUrl(m_loadingUrl); } return QWebPage::acceptNavigationRequest(frame, request, type); } + QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) { Q_UNUSED(type); if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) m_openInNewTab = true; - if (m_openInNewTab) { + if (m_openInNewTab) + { m_openInNewTab = false; return mainWindow()->tabWidget()->newTab()->page(); } @@ -108,20 +115,11 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) return mainWindow->currentTab()->page(); } -// #if !defined(QT_NO_UITOOLS) -// QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) -// { -// Q_UNUSED(url); -// Q_UNUSED(paramNames); -// Q_UNUSED(paramValues); -// QUiLoader loader; -// return loader.createWidget(classId, view()); -// } -// #endif // !defined(QT_NO_UITOOLS) void WebPage::handleUnsupportedContent(QNetworkReply *reply) { - if (reply->error() == QNetworkReply::NoError) { + if (reply->error() == QNetworkReply::NoError) + { BrowserApplication::downloadManager()->handleUnsupportedContent(reply); return; } @@ -140,16 +138,19 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) imageBuffer.open(QBuffer::ReadWrite); QIcon icon = view()->style()->standardIcon(QStyle::SP_MessageBoxWarning, 0, view()); QPixmap pixmap = icon.pixmap(QSize(32,32)); - if (pixmap.save(&imageBuffer, "PNG")) { + if (pixmap.save(&imageBuffer, "PNG")) + { html.replace(QLatin1String("IMAGE_BINARY_DATA_HERE"), QString(QLatin1String(imageBuffer.buffer().toBase64()))); } QList frames; frames.append(mainFrame()); - while (!frames.isEmpty()) { + while (!frames.isEmpty()) + { QWebFrame *frame = frames.takeFirst(); - if (frame->url() == reply->url()) { + if (frame->url() == reply->url()) + { frame->setHtml(html, reply->url()); return; } @@ -157,36 +158,37 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) foreach(QWebFrame *frame, children) frames.append(frame); } - if (m_loadingUrl == reply->url()) { + if (m_loadingUrl == reply->url()) + { mainFrame()->setHtml(html, reply->url()); } } +// ------------------------------------------------------------------------------------------------------------------------------------------------------ + + WebView::WebView(QWidget* parent) : QWebView(parent) , m_progress(0) , m_page(new WebPage(this)) { setPage(m_page); - connect(page(), SIGNAL(statusBarMessage(const QString&)), - SLOT(setStatusBarText(const QString&))); - connect(this, SIGNAL(loadProgress(int)), - this, SLOT(setProgress(int))); - connect(this, SIGNAL(loadFinished(bool)), - this, SLOT(loadFinished())); - connect(page(), SIGNAL(loadingUrl(const QUrl&)), - this, SIGNAL(urlChanged(const QUrl &))); - connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), - this, SLOT(downloadRequested(const QNetworkRequest &))); + connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); + connect(this, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int))); + connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished())); + connect(page(), SIGNAL(loadingUrl(const QUrl&)), this, SIGNAL(urlChanged(const QUrl &))); + connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &))); page()->setForwardUnsupportedContent(true); } + void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); - if (!r.linkUrl().isEmpty()) { + if (!r.linkUrl().isEmpty()) + { QMenu menu(this); menu.addAction(pageAction(QWebPage::OpenLinkInNewWindow)); menu.addAction(i18n("Open in New Tab"), this, SLOT(openLinkInNewTab())); @@ -203,9 +205,11 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) QWebView::contextMenuEvent(event); } + void WebView::wheelEvent(QWheelEvent *event) { - if (QApplication::keyboardModifiers() & Qt::ControlModifier) { + if (QApplication::keyboardModifiers() & Qt::ControlModifier) + { int numDegrees = event->delta() / 8; int numSteps = numDegrees / 15; setTextSizeMultiplier(textSizeMultiplier() + numSteps * 0.1); @@ -215,46 +219,55 @@ void WebView::wheelEvent(QWheelEvent *event) QWebView::wheelEvent(event); } + void WebView::openLinkInNewTab() { m_page->m_openInNewTab = true; pageAction(QWebPage::OpenLinkInNewWindow)->trigger(); } + void WebView::setProgress(int progress) { m_progress = progress; } + void WebView::loadFinished() { - if (100 != m_progress) { + if (m_progress != 100) + { qWarning() << "Recieved finished signal while progress is still:" << progress() << "Url:" << url(); } m_progress = 0; } -void WebView::loadUrl(const QUrl &url) + +void WebView::loadUrl(const KUrl &url) { m_initialUrl = url; load(url); } + QString WebView::lastStatusBarText() const { return m_statusBarText; } -QUrl WebView::url() const + +KUrl WebView::url() const { - QUrl url = QWebView::url(); - if (!url.isEmpty()) + KUrl url = QWebView::url(); + if ( !url.isEmpty() ) + { return url; - + } return m_initialUrl; } + void WebView::mousePressEvent(QMouseEvent *event) { m_page->m_pressedButtons = event->buttons(); @@ -262,22 +275,27 @@ void WebView::mousePressEvent(QMouseEvent *event) QWebView::mousePressEvent(event); } + void WebView::mouseReleaseEvent(QMouseEvent *event) { QWebView::mouseReleaseEvent(event); - if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) { - QUrl url(QApplication::clipboard()->text(QClipboard::Selection)); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { + if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) + { + KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + { setUrl(url); } } } + void WebView::setStatusBarText(const QString &string) { m_statusBarText = string; } + void WebView::downloadRequested(const QNetworkRequest &request) { BrowserApplication::downloadManager()->download(request); diff --git a/src/webview.h b/src/webview.h index f81544a0..b2e97efb 100644 --- a/src/webview.h +++ b/src/webview.h @@ -21,6 +21,8 @@ #ifndef WEBVIEW_H #define WEBVIEW_H +#include + #include QT_BEGIN_NAMESPACE @@ -33,12 +35,13 @@ QT_END_NAMESPACE class BrowserMainWindow; + class WebPage : public QWebPage { Q_OBJECT signals: - void loadingUrl(const QUrl &url); + void loadingUrl(const QUrl &url); // WARNING has to be QUrl!! public: WebPage(QObject *parent = 0); @@ -58,9 +61,12 @@ private: Qt::KeyboardModifiers m_keyboardModifiers; Qt::MouseButtons m_pressedButtons; bool m_openInNewTab; - QUrl m_loadingUrl; + KUrl m_loadingUrl; }; + +// --------------------------------------------------------------------------------------------------------------------------------------- + class WebView : public QWebView { Q_OBJECT @@ -69,8 +75,8 @@ public: WebView(QWidget *parent = 0); WebPage *webPage() const { return m_page; } - void loadUrl(const QUrl &url); - QUrl url() const; + void loadUrl(const KUrl &url); + KUrl url() const; QString lastStatusBarText() const; inline int progress() const { return m_progress; } @@ -90,7 +96,7 @@ private slots: private: QString m_statusBarText; - QUrl m_initialUrl; + KUrl m_initialUrl; int m_progress; WebPage *m_page; }; -- cgit v1.2.1 From d3ae019349f53901a93f42fbad5d65b6f9b40fe6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Dec 2008 01:34:44 +0100 Subject: QSettings --> KConfig --- src/browserapplication.cpp | 106 +++++++++++++++++---------------------------- src/browserapplication.h | 1 - src/browsermainwindow.cpp | 47 +++++++++----------- src/browsermainwindow.h | 5 +-- 4 files changed, 61 insertions(+), 98 deletions(-) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index a79f28b2..a35bab6f 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -94,19 +93,14 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); QString localSysName = QLocale::system().name(); - installTranslator(QLatin1String("qt_") + localSysName); - - QSettings settings; - settings.beginGroup(QLatin1String("sessions")); - m_lastSession = settings.value(QLatin1String("lastSession")).toByteArray(); - settings.endGroup(); + KConfig config("rekonqrc"); + KConfigGroup group = config.group("sessions"); + m_lastSession = group.readEntry( QString("lastSession"), QByteArray() ); QTimer::singleShot(0, this, SLOT( postLaunch() ) ); } - - BrowserApplication::~BrowserApplication() { delete s_downloadManager; @@ -115,27 +109,12 @@ BrowserApplication::~BrowserApplication() } - -// #if defined(Q_WS_MAC) -// void BrowserApplication::lastWindowClosed() -// { -// clean(); -// BrowserMainWindow *mw = new BrowserMainWindow; -// mw->slotHome(); -// m_mainWindows.prepend(mw); -// } -// #endif - - - BrowserApplication *BrowserApplication::instance() { return (static_cast(QCoreApplication::instance())); } - - /*! Any actions that can be delayed until the window is visible */ @@ -168,31 +147,28 @@ void BrowserApplication::postLaunch() void BrowserApplication::loadSettings() { - QSettings settings; - settings.beginGroup(QLatin1String("websettings")); - + KConfig config("rekonqrc"); + KConfigGroup group = config.group("Appearance Settings"); + QWebSettings *defaultSettings = QWebSettings::globalSettings(); QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); QFont standardFont = QFont(standardFontFamily, standardFontSize); - standardFont = qVariantValue(settings.value(QLatin1String("standardFont"), standardFont)); + standardFont = qVariantValue( group.readEntry( QString("standardFont"), standardFont ) ); + defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); QFont fixedFont = QFont(fixedFontFamily, fixedFontSize); - fixedFont = qVariantValue(settings.value(QLatin1String("fixedFont"), fixedFont)); + fixedFont = qVariantValue(group.readEntry( QString("fixedFont"), fixedFont ) ); + defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); - defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool()); - defaultSettings->setAttribute(QWebSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool()); - - QUrl url = settings.value(QLatin1String("userStyleSheet")).toUrl(); - defaultSettings->setUserStyleSheetUrl(url); - - settings.endGroup(); + defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, group.readEntry( QString("enableJavascript"), true ) ); + defaultSettings->setAttribute(QWebSettings::PluginsEnabled, group.readEntry( QString("enablePlugins"), true ) ); } @@ -203,7 +179,9 @@ QList BrowserApplication::mainWindows() clean(); QList list; for (int i = 0; i < m_mainWindows.count(); ++i) + { list.append(m_mainWindows.at(i)); + } return list; } @@ -214,13 +192,15 @@ void BrowserApplication::clean() { // cleanup any deleted main windows first for (int i = m_mainWindows.count() - 1; i >= 0; --i) + { if (m_mainWindows.at(i).isNull()) + { m_mainWindows.removeAt(i); + } + } } - - void BrowserApplication::saveSession() { QWebSettings *globalSettings = QWebSettings::globalSettings(); @@ -229,9 +209,8 @@ void BrowserApplication::saveSession() clean(); - QSettings settings; - settings.beginGroup(QLatin1String("sessions")); - + KConfig config("rekonqrc"); + KConfigGroup group = config.group("sessions"); QByteArray data; QBuffer buffer(&data); QDataStream stream(&buffer); @@ -239,22 +218,20 @@ void BrowserApplication::saveSession() stream << m_mainWindows.count(); for (int i = 0; i < m_mainWindows.count(); ++i) + { stream << m_mainWindows.at(i)->saveState(); - settings.setValue(QLatin1String("lastSession"), data); - settings.endGroup(); + } + + group.writeEntry( QString("lastSession"), data ); } - - bool BrowserApplication::canRestoreSession() const { return !m_lastSession.isEmpty(); } - - void BrowserApplication::restoreLastSession() { QList windows; @@ -294,16 +271,6 @@ bool BrowserApplication::isTheOnlyBrowser() const } - -void BrowserApplication::installTranslator(const QString &name) -{ - QTranslator *translator = new QTranslator(this); - translator->load(name, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - KApplication::installTranslator(translator); -} - - - void BrowserApplication::openUrl(const KUrl &url) { mainWindow()->loadPage( url.url() ); @@ -338,15 +305,19 @@ void BrowserApplication::newLocalSocketConnection() QTextStream stream(socket); QString url; stream >> url; - if (!url.isEmpty()) { - QSettings settings; - settings.beginGroup(QLatin1String("general")); - int openLinksIn = settings.value(QLatin1String("openLinksIn"), 0).toInt(); - settings.endGroup(); + if (!url.isEmpty()) + { + KConfig config("rekonqrc"); + KConfigGroup group = config.group("Global Settings"); + int openLinksIn = group.readEntry( QString("openLinksIn"), QString().toInt() ); if (openLinksIn == 1) + { newMainWindow(); + } else + { mainWindow()->tabWidget()->newTab(); + } openUrl(url); } delete socket; @@ -362,11 +333,10 @@ CookieJar *BrowserApplication::cookieJar() } - - DownloadManager *BrowserApplication::downloadManager() { - if (!s_downloadManager) { + if (!s_downloadManager) + { s_downloadManager = new DownloadManager(); } return s_downloadManager; @@ -376,7 +346,8 @@ DownloadManager *BrowserApplication::downloadManager() NetworkAccessManager *BrowserApplication::networkAccessManager() { - if (!s_networkAccessManager) { + if (!s_networkAccessManager) + { s_networkAccessManager = new NetworkAccessManager(); s_networkAccessManager->setCookieJar(new CookieJar); } @@ -387,7 +358,8 @@ NetworkAccessManager *BrowserApplication::networkAccessManager() HistoryManager *BrowserApplication::historyManager() { - if (!s_historyManager) { + if (!s_historyManager) + { s_historyManager = new HistoryManager(); QWebHistoryInterface::setDefaultInterface(s_historyManager); } diff --git a/src/browserapplication.h b/src/browserapplication.h index cee28895..eb6962ef 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -75,7 +75,6 @@ private slots: private: void clean(); - void installTranslator(const QString &name); static HistoryManager *s_historyManager; static DownloadManager *s_downloadManager; diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index ada00b5c..9abdb3ef 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -44,7 +44,6 @@ #include // Qt Includes -#include #include #include #include @@ -119,11 +118,10 @@ BrowserMainWindow::~BrowserMainWindow() void BrowserMainWindow::loadDefaultState() { - QSettings settings; - settings.beginGroup(QLatin1String("BrowserMainWindow")); - QByteArray data = settings.value(QLatin1String("defaultState")).toByteArray(); -// restoreState(data); // FIXME re-enable me! - settings.endGroup(); + KConfig config("rekonqrc"); + KConfigGroup group1 = config.group("BrowserMainWindow"); + QByteArray data = group1.readEntry(QString("defaultState"), QByteArray() ); + restoreState(data); } @@ -141,11 +139,10 @@ void BrowserMainWindow::save() { BrowserApplication::instance()->saveSession(); - QSettings settings; - settings.beginGroup(QLatin1String("BrowserMainWindow")); + KConfig config("rekonqrc"); + KConfigGroup group1 = config.group("BrowserMainWindow"); QByteArray data = saveState(false); - settings.setValue(QLatin1String("defaultState"), data); - settings.endGroup(); + group1.writeEntry( QString("defaultState"), data ); } @@ -164,8 +161,7 @@ QByteArray BrowserMainWindow::saveState(bool withTabs) const stream << qint32(version); stream << size(); - stream << !m_navigationBar->isHidden(); -// stream << !statusBar()->isHidden(); // FIXME strange error ???? +// stream << !( statusBar()->isHidden() ); FIXME if (withTabs) stream << tabWidget()->saveState(); else @@ -180,36 +176,36 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) int version = 2; QByteArray sd = state; QDataStream stream(&sd, QIODevice::ReadOnly); - if (stream.atEnd()) + if ( stream.atEnd() ) + { return false; + } qint32 marker; qint32 v; stream >> marker; stream >> v; if (marker != BrowserMainWindowMagic || v != version) + { return false; + } QSize size; - bool showToolbar; - bool showStatusbar; + bool showStatusbar = true; QByteArray tabState; stream >> size; - stream >> showToolbar; - stream >> showStatusbar; +// stream >> showStatusbar; FIXME see 30 lines over.. stream >> tabState; resize(size); - - m_navigationBar->setVisible(showToolbar); - statusBar()->setVisible(showStatusbar); updateStatusbarActionText(showStatusbar); - if (!tabWidget()->restoreState(tabState)) + if ( !tabWidget()->restoreState(tabState) ) + { return false; - + } return true; } @@ -785,9 +781,9 @@ void BrowserMainWindow::slotViewPageSource() void BrowserMainWindow::slotHome() { - QSettings settings; - settings.beginGroup(QLatin1String("MainWindow")); - QString home = settings.value(QLatin1String("home"), QLatin1String("http://www.kde.org/")).toString(); + KConfig config("rekonqrc"); + KConfigGroup group = config.group("Global Settings"); + QString home = group.readEntry( QString("home"), QString("http://www.kde.org/") ); loadPage(home); } @@ -858,7 +854,6 @@ WebView *BrowserMainWindow::currentTab() const } - void BrowserMainWindow::slotLoadProgress(int progress) { if (progress < 100 && progress > 0) diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 237f872d..e952eec2 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -34,9 +34,6 @@ #include #include -// // Qt Includes -// #include - class AutoSaver; class QWebFrame; @@ -47,7 +44,7 @@ class WebView; The MainWindow of the Browser Application. Handles the tab widget and all the actions - */ +*/ class BrowserMainWindow : public KMainWindow { Q_OBJECT -- cgit v1.2.1 From 9b508f95a69ba453bcd21780ace7ababaeeb797e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Dec 2008 01:47:03 +0100 Subject: Completely removed QSettings! --- src/browserapplication.cpp | 2 -- src/history.cpp | 89 +++++++++++++++++++++++++--------------------- 2 files changed, 48 insertions(+), 43 deletions(-) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index a35bab6f..55c60ae9 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -38,8 +38,6 @@ // Qt Includes #include #include -#include -#include #include #include #include diff --git a/src/history.cpp b/src/history.cpp index 43714166..930e73ae 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -18,32 +18,23 @@  *  * ============================================================ */ - +// Local Includes #include "history.h" #include "autosaver.h" #include "browserapplication.h" -#include -#include -#include -#include -#include -#include -#include +// Qt Includes +#include +#include +#include #include - -#include -#include -#include -#include - -#include -#include - #include +// KDE Includes +#include + static const unsigned int HISTORY_VERSION = 23; @@ -227,9 +218,9 @@ void HistoryManager::clear() void HistoryManager::loadSettings() { // load settings - QSettings settings; - settings.beginGroup(QLatin1String("history")); - m_historyLimit = settings.value(QLatin1String("historyLimit"), 30).toInt(); + KConfig config("rekonqrc"); + KConfigGroup group = config.group("history"); + m_historyLimit = group.readEntry( QString("historyLimit"), 30 ); } @@ -242,7 +233,8 @@ void HistoryManager::load() + QLatin1String("/history")); if (!historyFile.exists()) return; - if (!historyFile.open(QFile::ReadOnly)) { + if (!historyFile.open(QFile::ReadOnly)) + { qWarning() << "Unable to open history file" << historyFile.fileName(); return; } @@ -256,7 +248,8 @@ void HistoryManager::load() QDataStream stream; QBuffer buffer; stream.setDevice(&buffer); - while (!historyFile.atEnd()) { + while ( !historyFile.atEnd() ) + { in >> data; buffer.close(); buffer.setBuffer(&data); @@ -273,25 +266,27 @@ void HistoryManager::load() if (!item.dateTime.isValid()) continue; - if (item == lastInsertedItem) { + if ( item == lastInsertedItem ) + { if (lastInsertedItem.title.isEmpty() && !list.isEmpty()) list[0].title = item.title; continue; } - if (!needToSort && !list.isEmpty() && lastInsertedItem < item) + if ( !needToSort && !list.isEmpty() && lastInsertedItem < item ) needToSort = true; list.prepend(item); lastInsertedItem = item; } if (needToSort) - qSort(list.begin(), list.end()); + qSort( list.begin(), list.end() ); setHistory(list, true); // If we had to sort re-write the whole history sorted - if (needToSort) { + if (needToSort) + { m_lastSavedUrl = QString(); m_saveTimer->changeOccurred(); } @@ -300,16 +295,19 @@ void HistoryManager::load() void HistoryManager::save() { - QSettings settings; - settings.beginGroup(QLatin1String("history")); - settings.setValue(QLatin1String("historyLimit"), m_historyLimit); + KConfig config("rekonqrc"); + KConfigGroup group = config.group("history"); + group.writeEntry( QString("historyLimit"), m_historyLimit ); bool saveAll = m_lastSavedUrl.isEmpty(); int first = m_history.count() - 1; - if (!saveAll) { + if (!saveAll) + { // find the first one to save - for (int i = 0; i < m_history.count(); ++i) { - if (m_history.at(i).url == m_lastSavedUrl) { + for (int i = 0; i < m_history.count(); ++i) + { + if (m_history.at(i).url == m_lastSavedUrl) + { first = i - 1; break; } @@ -331,20 +329,25 @@ void HistoryManager::save() QTemporaryFile tempFile; tempFile.setAutoRemove(false); bool open = false; - if (saveAll) { + if (saveAll) + { open = tempFile.open(); - } else { + } + else + { open = historyFile.open(QFile::Append); } - if (!open) { + if (!open) + { qWarning() << "Unable to open history file for saving" << (saveAll ? tempFile.fileName() : historyFile.fileName()); return; } QDataStream out(saveAll ? &tempFile : &historyFile); - for (int i = first; i >= 0; --i) { + for (int i = first; i >= 0; --i) + { QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); HistoryItem item = m_history.at(i); @@ -353,7 +356,8 @@ void HistoryManager::save() } tempFile.close(); - if (saveAll) { + if (saveAll) + { if (historyFile.exists() && !historyFile.remove()) qWarning() << "History: error removing old history." << historyFile.errorString(); if (!tempFile.rename(historyFile.fileName())) @@ -363,9 +367,9 @@ void HistoryManager::save() } - // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) : QAbstractTableModel(parent) , m_history(history) @@ -401,8 +405,10 @@ void HistoryModel::entryUpdated(int offset) QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal - && role == Qt::DisplayRole) { - switch (section) { + && role == Qt::DisplayRole) + { + switch (section) + { case 0: return i18n("Title"); case 1: return i18n("Address"); } @@ -418,7 +424,8 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const return QVariant(); const HistoryItem &item = lst.at(index.row()); - switch (role) { + switch (role) + { case DateTimeRole: return item.dateTime; case DateRole: -- cgit v1.2.1 From 100ee731673d193a18138dbc6037771c71f1c486 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Dec 2008 11:55:31 +0100 Subject: Added releases dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 51b75647..5f41406a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ qtdemobrowser +releases -- cgit v1.2.1 From 689ec1f948776a747b640cac2d0aee865948429e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 5 Dec 2008 11:55:59 +0100 Subject: Fully using KConfig files to manage cookies and settings --- src/cookiejar.cpp | 153 ++++++++++++++++++++++++++++--------------- src/networkaccessmanager.cpp | 35 ++++++---- 2 files changed, 125 insertions(+), 63 deletions(-) diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index 9a6d8577..396052b9 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -23,21 +23,15 @@ #include "cookiejar.h" #include "autosaver.h" +// KDE Includes +#include +#include + // Qt Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include + #include static const unsigned int JAR_VERSION = 23; @@ -69,7 +63,8 @@ QDataStream &operator>>(QDataStream &stream, QList &list) QByteArray value; stream >> value; QList newCookies = QNetworkCookie::parseCookies(value); - if (newCookies.count() == 0 && value.length() != 0) { + if (newCookies.count() == 0 && value.length() != 0) + { qWarning() << "CookieJar: Unable to parse saved cookie:" << value; } for (int j = 0; j < newCookies.count(); ++j) @@ -109,31 +104,43 @@ void CookieJar::load() return; // load cookies and exceptions qRegisterMetaTypeStreamOperators >("QList"); - QSettings cookieSettings(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/cookies.ini"), QSettings::IniFormat); - setAllCookies(qvariant_cast >(cookieSettings.value(QLatin1String("cookies")))); - cookieSettings.beginGroup(QLatin1String("Exceptions")); - m_exceptions_block = cookieSettings.value(QLatin1String("block")).toStringList(); - m_exceptions_allow = cookieSettings.value(QLatin1String("allow")).toStringList(); - m_exceptions_allowForSession = cookieSettings.value(QLatin1String("allowForSession")).toStringList(); - qSort(m_exceptions_block.begin(), m_exceptions_block.end()); - qSort(m_exceptions_allow.begin(), m_exceptions_allow.end()); - qSort(m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end()); + + QString filepath = KStandardDirs::locateLocal("appdata", "cookies.ini"); + KConfig iniconfig( filepath ); + + KConfigGroup inigroup1 = iniconfig.group("general"); + + QStringList cookieStringList = inigroup1.readEntry( QString("cookies"), QStringList() ); + QList cookieNetworkList; + foreach( QString str, cookieStringList ) + { + cookieNetworkList << QNetworkCookie( str.toLocal8Bit() ); + } + setAllCookies( cookieNetworkList ); + + KConfigGroup inigroup2 = iniconfig.group("exceptions"); + m_exceptions_block = inigroup2.readEntry( QString("block") , QStringList() ); + m_exceptions_allow = inigroup2.readEntry( QString("allow"), QStringList() ); + m_exceptions_allowForSession = inigroup2.readEntry( QString("allowForSession"), QStringList() ); + + qSort( m_exceptions_block.begin(), m_exceptions_block.end() ); + qSort( m_exceptions_allow.begin(), m_exceptions_allow.end() ); + qSort( m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end() ); loadSettings(); } void CookieJar::loadSettings() { - QSettings settings; - settings.beginGroup(QLatin1String("cookies")); - QByteArray value = settings.value(QLatin1String("acceptCookies"), - QLatin1String("AcceptOnlyFromSitesNavigatedTo")).toByteArray(); + KConfig config("rekonqrc"); + KConfigGroup group = config.group("cookies"); + QByteArray value = group.readEntry( QString("acceptCookies"), QByteArray("AcceptOnlyFromSitesNavigatedTo") ); QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AcceptPolicy")); m_acceptCookies = acceptPolicyEnum.keyToValue(value) == -1 ? AcceptOnlyFromSitesNavigatedTo : static_cast(acceptPolicyEnum.keyToValue(value)); - value = settings.value(QLatin1String("keepCookiesUntil"), QLatin1String("KeepUntilExpire")).toByteArray(); + value = group.readEntry( QString("keepCookiesUntil"), QByteArray("KeepUntilExpire") ); QMetaEnum keepPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("KeepPolicy")); m_keepCookies = keepPolicyEnum.keyToValue(value) == -1 ? KeepUntilExpire : @@ -154,30 +161,43 @@ void CookieJar::save() QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); if (directory.isEmpty()) directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); - if (!QFile::exists(directory)) { + if (!QFile::exists(directory)) + { QDir dir; dir.mkpath(directory); } - QSettings cookieSettings(directory + QLatin1String("/cookies.ini"), QSettings::IniFormat); + + QString filepath = KStandardDirs::locateLocal("appdata", "cookies.ini"); + KConfig iniconfig( filepath ); + + KConfigGroup inigroup1 = iniconfig.group("general"); QList cookies = allCookies(); - for (int i = cookies.count() - 1; i >= 0; --i) { + for (int i = cookies.count() - 1; i >= 0; --i) + { if (cookies.at(i).isSessionCookie()) cookies.removeAt(i); } - cookieSettings.setValue(QLatin1String("cookies"), qVariantFromValue >(cookies)); - cookieSettings.beginGroup(QLatin1String("Exceptions")); - cookieSettings.setValue(QLatin1String("block"), m_exceptions_block); - cookieSettings.setValue(QLatin1String("allow"), m_exceptions_allow); - cookieSettings.setValue(QLatin1String("allowForSession"), m_exceptions_allowForSession); + + QStringList cookieStringList; + foreach( QNetworkCookie cook, cookies ) + { + cookieStringList << QString( cook.toRawForm() ); + } + inigroup1.writeEntry( QString("cookies"), cookieStringList ); + + KConfigGroup inigroup2 = iniconfig.group("exceptions"); + inigroup2.writeEntry( QString("block"), m_exceptions_block ); + inigroup2.writeEntry( QString("allow"), m_exceptions_allow ); + inigroup2.writeEntry( QString("allowForSession"), m_exceptions_allowForSession ); // save cookie settings - QSettings settings; - settings.beginGroup(QLatin1String("cookies")); - QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AcceptPolicy")); - settings.setValue(QLatin1String("acceptCookies"), QLatin1String(acceptPolicyEnum.valueToKey(m_acceptCookies))); + KConfig config("rekonqrc"); + KConfigGroup group = config.group("cookies"); + QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator( staticMetaObject.indexOfEnumerator("AcceptPolicy") ); + group.writeEntry( QString("acceptCookies"), QString( acceptPolicyEnum.valueToKey(m_acceptCookies) ) ); QMetaEnum keepPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("KeepPolicy")); - settings.setValue(QLatin1String("keepCookiesUntil"), QLatin1String(keepPolicyEnum.valueToKey(m_keepCookies))); + group.writeEntry( QString("keepCookiesUntil"), QString( keepPolicyEnum.valueToKey(m_keepCookies) ) ); } void CookieJar::purgeOldCookies() @@ -187,7 +207,8 @@ void CookieJar::purgeOldCookies() return; int oldCount = cookies.count(); QDateTime now = QDateTime::currentDateTime(); - for (int i = cookies.count() - 1; i >= 0; --i) { + for (int i = cookies.count() - 1; i >= 0; --i) + { if (!cookies.at(i).isSessionCookie() && cookies.at(i).expirationDate() < now) cookies.removeAt(i); } @@ -204,7 +225,8 @@ QList CookieJar::cookiesForUrl(const QUrl &url) const that->load(); QWebSettings *globalSettings = QWebSettings::globalSettings(); - if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) { + if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + { QList noCookies; return noCookies; } @@ -229,24 +251,30 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const bool addedCookies = false; // pass exceptions bool acceptInitially = (m_acceptCookies != AcceptNever); - if ((acceptInitially && !eBlock) - || (!acceptInitially && (eAllow || eAllowSession))) { + if ( (acceptInitially && !eBlock) || (!acceptInitially && (eAllow || eAllowSession) ) ) + { // pass url domain == cookie domain QDateTime soon = QDateTime::currentDateTime(); soon = soon.addDays(90); - foreach(QNetworkCookie cookie, cookieList) { + foreach(QNetworkCookie cookie, cookieList) + { QList lst; if (m_keepCookies == KeepUntilTimeLimit && !cookie.isSessionCookie() - && cookie.expirationDate() > soon) { + && cookie.expirationDate() > soon) + { cookie.setExpirationDate(soon); } lst += cookie; - if (QNetworkCookieJar::setCookiesFromUrl(lst, url)) { + if (QNetworkCookieJar::setCookiesFromUrl(lst, url)) + { addedCookies = true; - } else { + } + else + { // finally force it in if wanted - if (m_acceptCookies == AcceptAlways) { + if (m_acceptCookies == AcceptAlways) + { QList cookies = allCookies(); cookies += cookie; setAllCookies(cookies); @@ -260,13 +288,16 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const } } - if (addedCookies) { + if (addedCookies) + { m_saveTimer->changeOccurred(); emit cookiesChanged(); } return addedCookies; } + + CookieJar::AcceptPolicy CookieJar::acceptPolicy() const { if (!m_loaded) @@ -274,6 +305,8 @@ CookieJar::AcceptPolicy CookieJar::acceptPolicy() const return m_acceptCookies; } + + void CookieJar::setAcceptPolicy(AcceptPolicy policy) { if (!m_loaded) @@ -284,6 +317,8 @@ void CookieJar::setAcceptPolicy(AcceptPolicy policy) m_saveTimer->changeOccurred(); } + + CookieJar::KeepPolicy CookieJar::keepPolicy() const { if (!m_loaded) @@ -291,6 +326,8 @@ CookieJar::KeepPolicy CookieJar::keepPolicy() const return m_keepCookies; } + + void CookieJar::setKeepPolicy(KeepPolicy policy) { if (!m_loaded) @@ -301,6 +338,8 @@ void CookieJar::setKeepPolicy(KeepPolicy policy) m_saveTimer->changeOccurred(); } + + QStringList CookieJar::blockedCookies() const { if (!m_loaded) @@ -308,6 +347,8 @@ QStringList CookieJar::blockedCookies() const return m_exceptions_block; } + + QStringList CookieJar::allowedCookies() const { if (!m_loaded) @@ -315,6 +356,8 @@ QStringList CookieJar::allowedCookies() const return m_exceptions_allow; } + + QStringList CookieJar::allowForSessionCookies() const { if (!m_loaded) @@ -322,6 +365,8 @@ QStringList CookieJar::allowForSessionCookies() const return m_exceptions_allowForSession; } + + void CookieJar::setBlockedCookies(const QStringList &list) { if (!m_loaded) @@ -331,6 +376,8 @@ void CookieJar::setBlockedCookies(const QStringList &list) m_saveTimer->changeOccurred(); } + + void CookieJar::setAllowedCookies(const QStringList &list) { if (!m_loaded) @@ -340,6 +387,8 @@ void CookieJar::setAllowedCookies(const QStringList &list) m_saveTimer->changeOccurred(); } + + void CookieJar::setAllowForSessionCookies(const QStringList &list) { if (!m_loaded) diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 01ab06ce..79549d25 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -26,8 +26,10 @@ #include "ui_passworddialog.h" #include "ui_proxy.h" +// KDE Includes +#include + // Qt Includes -#include #include #include #include @@ -52,24 +54,33 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) loadSettings(); } + void NetworkAccessManager::loadSettings() { - QSettings settings; - settings.beginGroup(QLatin1String("proxy")); + KConfig config("rekonqrc"); + KConfigGroup group = config.group("proxy"); + QNetworkProxy proxy; - if (settings.value(QLatin1String("enabled"), false).toBool()) { - if (settings.value(QLatin1String("type"), 0).toInt() == 0) + if ( group.readEntry( QString("enabled"), false) ) + { + if ( group.readEntry( QString("type"), 0) == 0 ) + { proxy.setType(QNetworkProxy::Socks5Proxy); + } else + { proxy.setType(QNetworkProxy::HttpProxy); - proxy.setHostName(settings.value(QLatin1String("hostName")).toString()); - proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt()); - proxy.setUser(settings.value(QLatin1String("userName")).toString()); - proxy.setPassword(settings.value(QLatin1String("password")).toString()); + } + proxy.setHostName( group.readEntry( QString("hostName"), QString() ) ); + proxy.setPort( group.readEntry( QString("port"), 1080 ) ); + proxy.setUser( group.readEntry( QString("userName"), QString() ) ); + proxy.setPassword( group.readEntry( QString("password"), QString() ) ); } setProxy(proxy); } + + void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) { BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); @@ -87,7 +98,8 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent passwordDialog.introLabel->setText(introMessage); passwordDialog.introLabel->setWordWrap(true); - if (dialog.exec() == QDialog::Accepted) { + if (dialog.exec() == QDialog::Accepted) + { auth->setUser(passwordDialog.userNameLineEdit->text()); auth->setPassword(passwordDialog.passwordLineEdit->text()); } @@ -110,7 +122,8 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox proxyDialog.introLabel->setText(introMessage); proxyDialog.introLabel->setWordWrap(true); - if (dialog.exec() == QDialog::Accepted) { + if (dialog.exec() == QDialog::Accepted) + { auth->setUser(proxyDialog.userNameLineEdit->text()); auth->setPassword(proxyDialog.passwordLineEdit->text()); } -- cgit v1.2.1 From 75e3a98bb31afe389a5ac63b8f82423d019721a8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 10:25:23 +0100 Subject: more KDE-like menubar(s).. --- .gitignore | 1 - ChangeLog | 7 + TODO | 5 +- src/browsermainwindow.cpp | 71 +++---- src/browsermainwindow.h | 1 - src/findbar.cpp | 2 +- src/findbar.h | 4 +- src/tabwidget.cpp | 7 +- src/tabwidget.h | 4 +- src/tags | 494 ++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 537 insertions(+), 59 deletions(-) create mode 100644 ChangeLog create mode 100644 src/tags diff --git a/.gitignore b/.gitignore index 5f41406a..0beafa56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ qtdemobrowser releases - diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..87465a3c --- /dev/null +++ b/ChangeLog @@ -0,0 +1,7 @@ +0.0.2 +- QUrl --> KUrl +- more KDE-like toolbars + + +0.0.1 + diff --git a/TODO b/TODO index 3aae668b..c2ac09d0 100644 --- a/TODO +++ b/TODO @@ -5,14 +5,15 @@ Road to 0.0.1 (first release) + some porting NEXT.. +- system SELECT ALL - better FULL SCREEN - simplify history -- QUrl --> KUrl ++ QUrl --> KUrl - KDE download = Kjob && Kget - adjust toolbar(s) -search bar - url bar -- KDEize menubar (settings) ++ KDEize menubar (settings) - configure dialog (A-LA amarok, konqueror) - dbus support (?!) - KWallet support diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 9abdb3ef..f17f450a 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -265,14 +265,15 @@ void BrowserMainWindow::setupMenu() editMenu->addSeparator(); - editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); - editMenu->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); + KAction *m_selectall = KStandardAction::selectAll( this , 0 , this ); + editMenu->addAction( m_selectall ); + m_tabWidget->addWebAction(m_selectall, QWebPage::SelectEndOfDocument ); editMenu->addSeparator(); - editMenu->addAction( i18n("&Preferences"), this, SLOT(slotPreferences()), i18n("Ctrl+,")); - + editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); + editMenu->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); + editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); @@ -293,12 +294,20 @@ void BrowserMainWindow::setupMenu() m_reload->setShortcut(QKeySequence::Refresh); m_tabWidget->addWebAction(m_reload, QWebPage::Reload); - viewMenu->addAction( i18n("&Make Text Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); - viewMenu->addAction( i18n("&Make Text Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); - viewMenu->addAction( i18n("&Make Text Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); + viewMenu->addSeparator(); + + KMenu *fontMenu = new KMenu( i18n("Make Text..."), this ); + fontMenu->addAction( i18n("&Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); + fontMenu->addAction( i18n("&Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); + fontMenu->addAction( i18n("&Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); + + viewMenu->addMenu( fontMenu ); viewMenu->addSeparator(); - viewMenu->addAction( i18n("Page S&ource"), this, SLOT(slotViewPageSource()), i18n("Ctrl+Alt+U")); + + // TODO set encoding + + viewMenu->addAction( i18n("Page S&ource"), this, SLOT( slotViewPageSource() ), i18n("Ctrl+Alt+U")); action = (KAction *) viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); action->setCheckable(true); @@ -337,29 +346,21 @@ void BrowserMainWindow::setupMenu() BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); bookmarksMenu->setTitle( i18n("&Bookmarks") ); -// m_bookmarksMenu = new KMenu( i18n("&Bookmarks"), this ); -// -// KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); -// KBookmarkManager *mgr = KBookmarkManager::managerForExternalFile( bookfile.path() ); //FIXME hardcoded path -// KActionCollection * ac = new KActionCollection( this ); -// ac->addAction( "Add Bookmark" , KStandardAction::addBookmark( this, SLOT( slotAddBookmark() ) , this ) ); -// m_bookmarkMenu = new KBookmarkMenu( mgr , 0 , bookmarksMenu , ac ); - menuBar()->addMenu( bookmarksMenu ); - // ------------------------------------------------------------- WINDOW -------------------------------------------------------------------------------------------------- - m_windowMenu = (KMenu *) menuBar()->addMenu( i18n("&Window") ); - - connect(m_windowMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowWindowMenu())); - slotAboutToShowWindowMenu(); - // ------------------------------------------------------------- TOOLS ------------------------------------------------------------------------------------------------------ KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); + toolsMenu->addAction( i18n("Downloads"), this, SLOT( slotDownloadManager() ), i18n("Alt+Ctrl+D") ); toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); action->setCheckable(true); + // ------------------------------------------------------------- SETTINGS ------------------------------------------------------------------------------------------------------ + KMenu *settingsMenu = (KMenu *) menuBar()->addMenu( i18n("&Settings") ); + +// TODO settingsMenu->addAction( KStandardAction::configureToolbars(this, SLOT( ) , this ) ); + settingsMenu->addAction( KStandardAction::preferences(this, SLOT( slotPreferences() ) , this ) ); // ------------------------------------------------------------- HELP -------------------------------------------------------------------------------------------------- menuBar()->addMenu( helpMenu() ); @@ -898,30 +899,6 @@ void BrowserMainWindow::slotAboutToShowBackMenu() -void BrowserMainWindow::slotAboutToShowWindowMenu() -{ - m_windowMenu->clear(); - m_windowMenu->addAction(m_tabWidget->nextTabAction()); - m_windowMenu->addAction(m_tabWidget->previousTabAction()); - m_windowMenu->addSeparator(); - m_windowMenu->addAction( i18n("Downloads"), this, SLOT(slotDownloadManager()), QKeySequence( tr("Alt+Ctrl+L", "Download Manager"))); - - m_windowMenu->addSeparator(); - QList windows = BrowserApplication::instance()->mainWindows(); - for (int i = 0; i < windows.count(); ++i) - { - BrowserMainWindow *window = windows.at(i); - QAction *action = m_windowMenu->addAction(window->windowTitle(), this, SLOT(slotShowWindow())); - action->setData(i); - action->setCheckable(true); - if (window == this) - action->setChecked(true); - } -} - - - - void BrowserMainWindow::slotShowWindow() { if (KAction *action = qobject_cast(sender())) diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index e952eec2..811584f8 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -103,7 +103,6 @@ private slots: void slotSelectLineEdit(); void slotAboutToShowBackMenu(); - void slotAboutToShowWindowMenu(); // history related void slotOpenActionUrl(QAction *action); diff --git a/src/findbar.cpp b/src/findbar.cpp index 2d9e0d5c..feafb98e 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -29,7 +29,7 @@ #include -FindBar::FindBar(QMainWindow *parent) +FindBar::FindBar(KMainWindow *parent) : KToolBar( "FindBar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) { diff --git a/src/findbar.h b/src/findbar.h index ece34f83..4c0034a6 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -23,14 +23,14 @@ #include #include -#include +#include class FindBar : public KToolBar { Q_OBJECT public: - FindBar(QMainWindow *parent); + FindBar(KMainWindow *parent); ~FindBar(); KLineEdit *lineEdit(); diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 32d43d65..fc545bd3 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -190,7 +190,7 @@ void TabBar::reloadTab() } -// -------------------------------------------------------------------------------------------------------------------------------------------------------- +// --------------------------------------------------------------------------------------------------------------------------- TabWidget::TabWidget(QWidget *parent) @@ -276,7 +276,8 @@ void TabWidget::clear() // clear the recently closed tabs m_recentlyClosedTabs.clear(); // clear the line edit history - for (int i = 0; i < m_lineEdits->count(); ++i) { + for (int i = 0; i < m_lineEdits->count(); ++i) + { KLineEdit *qLineEdit = lineEdit(i); qLineEdit->setText(qLineEdit->text()); } @@ -827,7 +828,7 @@ bool TabWidget::restoreState(const QByteArray &state) } -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +// ---------------------------------------------------------------------------------------------------------------------------- WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) diff --git a/src/tabwidget.h b/src/tabwidget.h index 5a48072f..6e9f2f66 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -69,7 +69,7 @@ private: }; -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// ---------------------------------------------------------------------------------------------------------------------------- @@ -106,7 +106,7 @@ private: }; -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// ---------------------------------------------------------------------------------------------------------------------------- // KDE Includes #include diff --git a/src/tags b/src/tags new file mode 100644 index 00000000..d2fc52eb --- /dev/null +++ b/src/tags @@ -0,0 +1,494 @@ +!_TAG_FILE_FORMAT 2 /supported features/ +!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted/ +!_TAG_PROGRAM_AUTHOR Steve Kirkendall /kirkenda@cs.pdx.edu/ +!_TAG_PROGRAM_NAME Elvis Ctags // +!_TAG_PROGRAM_URL ftp://ftp.cs.pdx.edu/pub/elvis/README.html /official site/ +!_TAG_PROGRAM_VERSION 2.2.0 // +AUTOSAVER_H autosaver.h 22;" d ln:22 +AUTOSAVE_IN autosaver.cpp 28;" d ln:28 file: +AutoSaver autosaver.h /^class AutoSaver : public QObject {$/;" c ln:33 +AutoSaver browsermainwindow.h /^class AutoSaver;$/;" v ln:38 +AutoSaver cookiejar.h /^class AutoSaver;$/;" v ln:40 +AutoSaver downloadmanager.h /^class AutoSaver;$/;" v ln:74 +AutoSaver history.h /^class AutoSaver;$/;" v ln:67 +AutoSaver autosaver.cpp /^AutoSaver::AutoSaver(QObject *parent) : QObject(parent)$/;" f ln:31 class:AutoSaver +AutoSaver autosaver.cpp /^AutoSaver::~AutoSaver()$/;" f ln:36 class:AutoSaver +BOOKMARKS_H bookmarks.h 21;" d ln:21 +BROWSERAPPLICATION_H browserapplication.h 23;" d ln:23 +BROWSERMAINWINDOW_H browsermainwindow.h 23;" d ln:23 +BookmarksMenu bookmarks.h /^class BookmarksMenu : public KMenu$/;" c ln:54 +BookmarksMenu bookmarks.cpp /^BookmarksMenu::BookmarksMenu(KMainWindow *parent)$/;" f ln:61 class:BookmarksMenu +BrowserApplication browserapplication.h /^class BrowserApplication : public KApplication$/;" c ln:44 +BrowserApplication browserapplication.cpp /^BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &serverName)$/;" f ln:58 class:BrowserApplication +BrowserApplication browserapplication.cpp /^BrowserApplication::~BrowserApplication()$/;" f ln:102 class:BrowserApplication +BrowserMainWindow bookmarks.h /^class BrowserMainWindow;$/;" v ln:32 +BrowserMainWindow browserapplication.h /^class BrowserMainWindow;$/;" v ln:38 +BrowserMainWindow browsermainwindow.h /^class BrowserMainWindow : public KMainWindow $/;" c ln:48 +BrowserMainWindow webview.h /^class BrowserMainWindow;$/;" v ln:36 +BrowserMainWindow browsermainwindow.cpp /^BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags)$/;" f ln:61 class:BrowserMainWindow +BrowserMainWindow browsermainwindow.cpp /^BrowserMainWindow::~BrowserMainWindow()$/;" f ln:111 class:BrowserMainWindow +BrowserMainWindowMagic browsermainwindow.cpp /^static const qint32 BrowserMainWindowMagic = 0xba;$/;" v ln:150 file: +COOKIEJAR_H cookiejar.h 22;" d ln:22 +CookieExceptionsModel cookiejar.h /^class CookieExceptionsModel : public QAbstractTableModel$/;" c ln:155 +CookieExceptionsModel cookiejar.cpp /^CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent)$/;" f ln:574 class:CookieExceptionsModel +CookieJar browserapplication.h /^class CookieJar;$/;" v ln:39 +CookieJar cookiejar.h /^class CookieJar : public QNetworkCookieJar$/;" c ln:42 +CookieJar cookiejar.cpp /^CookieJar::CookieJar(QObject *parent)$/;" f ln:79 class:CookieJar +CookieJar cookiejar.cpp /^CookieJar::~CookieJar()$/;" f ln:87 class:CookieJar +CookieModel cookiejar.h /^class CookieModel : public QAbstractTableModel$/;" c ln:117 +CookieModel cookiejar.cpp /^CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent)$/;" f ln:407 class:CookieModel +CookiesDialog cookiejar.h /^class CookiesDialog : public QDialog, public Ui_CookiesDialog$/;" v ln:144 +CookiesDialog cookiejar.cpp /^CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) $/;" f ln:523 class:CookiesDialog +CookiesExceptionsDialog cookiejar.h /^class CookiesExceptionsDialog : public QDialog, public Ui_CookiesExceptionsDialog$/;" v ln:186 +CookiesExceptionsDialog cookiejar.cpp /^CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent)$/;" f ln:697 class:CookiesExceptionsDialog +DOWNLOADMANAGER_H downloadmanager.h 23;" d ln:23 +DownloadItem downloadmanager.h /^class DownloadItem : public QWidget, public Ui_DownloadItem$/;" v ln:33 +DownloadItem downloadmanager.cpp /^DownloadItem::DownloadItem(QNetworkReply *reply, bool requestFileName, QWidget *parent)$/;" f ln:46 class:DownloadItem +DownloadManager browserapplication.h /^class DownloadManager;$/;" v ln:40 +DownloadManager downloadmanager.h /^class DownloadManager : public QDialog, public Ui_DownloadDialog$/;" v ln:80 +DownloadManager downloadmanager.cpp /^DownloadManager::DownloadManager(QWidget *parent)$/;" f ln:307 class:DownloadManager +DownloadManager downloadmanager.cpp /^DownloadManager::~DownloadManager()$/;" f ln:326 class:DownloadManager +DownloadModel downloadmanager.h /^class DownloadModel;$/;" v ln:75 +DownloadModel downloadmanager.h /^class DownloadModel : public QAbstractListModel$/;" c ln:125 +DownloadModel downloadmanager.cpp /^DownloadModel::DownloadModel(DownloadManager *downloadManager, QObject *parent)$/;" f ln:506 class:DownloadModel +EDITTABLEVIEW_H edittableview.h 22;" d ln:22 +EDITTREEVIEW_H edittreeview.h 22;" d ln:22 +EditTableView edittableview.h /^class EditTableView : public QTableView$/;" c ln:26 +EditTableView edittableview.cpp /^EditTableView::EditTableView(QWidget *parent)$/;" f ln:24 class:EditTableView +EditTreeView edittreeview.h /^class EditTreeView : public QTreeView$/;" c ln:26 +EditTreeView edittreeview.cpp /^EditTreeView::EditTreeView(QWidget *parent)$/;" f ln:25 class:EditTreeView +FINDBAR_H findbar.h 21;" d ln:21 +FindBar findbar.h /^class FindBar : public KToolBar$/;" c ln:28 +FindBar findbar.cpp /^FindBar::FindBar(KMainWindow *parent)$/;" f ln:32 class:FindBar +FindBar findbar.cpp /^FindBar::~FindBar()$/;" f ln:59 class:FindBar +HISTORY_H history.h 23;" d ln:23 +HISTORY_VERSION history.cpp /^static const unsigned int HISTORY_VERSION = 23;$/;" v ln:39 file: +HistoryCompletionModel history.h /^class HistoryCompletionModel : public QAbstractProxyModel$/;" c ln:265 +HistoryCompletionModel history.cpp /^HistoryCompletionModel::HistoryCompletionModel(QObject *parent)$/;" f ln:981 class:HistoryCompletionModel +HistoryDialog history.h /^class HistoryDialog : public QDialog, public Ui_HistoryDialog$/;" v ln:342 +HistoryDialog history.cpp /^HistoryDialog::HistoryDialog(QWidget *parent, HistoryManager *setHistory) : QDialog(parent)$/;" f ln:698 class:HistoryDialog +HistoryFilterModel history.h /^class HistoryFilterModel;$/;" v ln:69 +HistoryFilterModel history.h /^class HistoryFilterModel : public QAbstractProxyModel$/;" c ln:168 +HistoryFilterModel history.cpp /^HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent)$/;" f ln:767 class:HistoryFilterModel +HistoryItem history.h /^class HistoryItem$/;" c ln:41 +HistoryManager browserapplication.h /^class HistoryManager;$/;" v ln:41 +HistoryManager history.h /^class HistoryManager : public QWebHistoryInterface$/;" c ln:73 +HistoryManager history.cpp /^HistoryManager::HistoryManager(QObject *parent)$/;" f ln:42 class:HistoryManager +HistoryManager history.cpp /^HistoryManager::~HistoryManager()$/;" f ln:65 class:HistoryManager +HistoryMenu history.h /^class HistoryMenu : public ModelMenu$/;" c ln:236 +HistoryMenu history.cpp /^HistoryMenu::HistoryMenu(QWidget *parent)$/;" f ln:614 class:HistoryMenu +HistoryMenuModel history.h /^class HistoryMenuModel : public QAbstractProxyModel$/;" c ln:214 +HistoryMenuModel history.cpp /^HistoryMenuModel::HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent)$/;" f ln:499 class:HistoryMenuModel +HistoryModel history.h /^class HistoryModel;$/;" v ln:68 +HistoryModel history.h /^class HistoryModel : public QAbstractTableModel$/;" c ln:133 +HistoryModel history.cpp /^HistoryModel::HistoryModel(HistoryManager *history, QObject *parent)$/;" f ln:373 class:HistoryModel +HistoryTreeModel history.h /^class HistoryTreeModel;$/;" v ln:70 +HistoryTreeModel history.h /^class HistoryTreeModel : public QAbstractProxyModel$/;" c ln:290 +HistoryTreeModel history.cpp /^HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent)$/;" f ln:1084 class:HistoryTreeModel +JAR_VERSION cookiejar.cpp /^static const unsigned int JAR_VERSION = 23;$/;" v ln:37 file: +KBookmarkOwner bookmarks.h /^class OwnBookMarks : public QObject , public KBookmarkOwner$/;" c ln:34 +MAXWAIT autosaver.cpp 29;" d ln:29 file: +MODELMENU_H modelmenu.h 23;" d ln:23 +MOVEDROWS history.cpp 494;" d ln:494 class:HistoryModel file: +ModelMenu modelmenu.h /^class ModelMenu : public QMenu$/;" c ln:34 +ModelMenu modelmenu.cpp /^ModelMenu::ModelMenu(QWidget * parent)$/;" f ln:24 class:ModelMenu +NETWORKACCESSMANAGER_H networkaccessmanager.h 22;" d ln:22 +NetworkAccessManager browserapplication.h /^class NetworkAccessManager;$/;" v ln:42 +NetworkAccessManager networkaccessmanager.h /^class NetworkAccessManager : public QNetworkAccessManager$/;" c ln:26 +NetworkAccessManager networkaccessmanager.cpp /^NetworkAccessManager::NetworkAccessManager(QObject *parent)$/;" f ln:43 class:NetworkAccessManager +OwnBookMarks bookmarks.h /^class OwnBookMarks : public QObject , public KBookmarkOwner$/;" v ln:34 +OwnBookMarks bookmarks.cpp /^OwnBookMarks::OwnBookMarks(KMainWindow *parent)$/;" f ln:30 class:OwnBookMarks +QAuthenticator webview.h /^class QAuthenticator;$/;" v ln:29 +QCompleter tabwidget.h /^class QCompleter;$/;" v ln:120 +QFileIconProvider downloadmanager.h /^class QFileIconProvider;$/;" v ln:77 +QKeyEvent cookiejar.h /^class QKeyEvent;$/;" v ln:37 +QLocalServer browserapplication.h /^class QLocalServer;$/;" v ln:35 +QMenu tabwidget.h /^class QMenu;$/;" v ln:121 +QMouseEvent webview.h /^class QMouseEvent;$/;" v ln:30 +QNetworkProxy webview.h /^class QNetworkProxy;$/;" v ln:31 +QNetworkReply webview.h /^class QNetworkReply;$/;" v ln:32 +QSortFilterProxyModel cookiejar.h /^class QSortFilterProxyModel;$/;" v ln:36 +QSslError webview.h /^class QSslError;$/;" v ln:33 +QStackedWidget tabwidget.h /^class QStackedWidget;$/;" v ln:122 +QWebFrame browsermainwindow.h /^class QWebFrame;$/;" v ln:39 +Q_DECLARE_METATYPE modelmenu.cpp /^Q_DECLARE_METATYPE(QModelIndex)$/;" f ln:120 +SEARCHBAR_H searchbar.h 22;" d ln:22 +SETTINGS_H settings.h 22;" d ln:22 +SQUEEZELABEL_H squeezelabel.h 22;" d ln:22 +SearchBar searchbar.h /^class SearchBar : public QWidget$/;" c ln:31 +SearchBar searchbar.cpp /^SearchBar::SearchBar(QWidget *parent) : $/;" f ln:27 class:SearchBar +SearchBar searchbar.cpp /^SearchBar::~SearchBar()$/;" f ln:41 class:SearchBar +Settings settings.h /^class SettingsDialog : public KDialog, private Ui::Settings$/;" c ln:33 class:Ui +SettingsDialog settings.h /^class SettingsDialog : public KDialog, private Ui::Settings$/;" v ln:33 +SettingsDialog settings.cpp /^SettingsDialog::SettingsDialog(QWidget *parent)$/;" f ln:41 class:SettingsDialog +SqueezeLabel squeezelabel.h /^class SqueezeLabel : public QLabel$/;" c ln:26 +SqueezeLabel squeezelabel.cpp /^SqueezeLabel::SqueezeLabel(QWidget *parent) : QLabel(parent)$/;" f ln:23 class:SqueezeLabel +TABWIDGET_H tabwidget.h 24;" d ln:24 +TabBar tabwidget.h /^class TabBar : public KTabBar$/;" c ln:33 +TabBar tabwidget.cpp /^TabBar::TabBar(QWidget *parent)$/;" f ln:36 class:TabBar +TabWidget browsermainwindow.h /^class TabWidget;$/;" v ln:40 +TabWidget tabwidget.h /^class TabWidget : public QTabWidget$/;" c ln:130 +TabWidget tabwidget.cpp /^TabWidget::TabWidget(QWidget *parent)$/;" f ln:196 class:TabWidget +TabWidgetMagic tabwidget.cpp /^static const qint32 TabWidgetMagic = 0xaa;$/;" v ln:768 file: +TreeProxyModel history.h /^class TreeProxyModel : public QSortFilterProxyModel$/;" c ln:326 +TreeProxyModel history.cpp /^TreeProxyModel::TreeProxyModel(QObject *parent) : QSortFilterProxyModel(parent)$/;" f ln:681 class:TreeProxyModel +URLBAR_H urlbar.h 21;" d ln:21 +Ui_CookiesDialog cookiejar.h /^class CookiesDialog : public QDialog, public Ui_CookiesDialog$/;" c ln:144 +Ui_CookiesExceptionsDialog cookiejar.h /^class CookiesExceptionsDialog : public QDialog, public Ui_CookiesExceptionsDialog$/;" c ln:186 +Ui_DownloadDialog downloadmanager.h /^class DownloadManager : public QDialog, public Ui_DownloadDialog$/;" c ln:80 +Ui_DownloadItem downloadmanager.h /^class DownloadItem : public QWidget, public Ui_DownloadItem$/;" c ln:33 +Ui_HistoryDialog history.h /^class HistoryDialog : public QDialog, public Ui_HistoryDialog$/;" c ln:342 +UrlBar urlbar.h /^class UrlBar : public QWidget$/;" c ln:35 +UrlBar urlbar.cpp /^UrlBar::UrlBar(QWidget *parent)$/;" f ln:30 class:UrlBar +UrlBar urlbar.cpp /^UrlBar::~UrlBar()$/;" f ln:55 class:UrlBar +WEBVIEW_H webview.h 22;" d ln:22 +WebActionMapper tabwidget.h /^class WebActionMapper : public QObject$/;" c ln:86 +WebActionMapper tabwidget.cpp /^WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent)$/;" f ln:834 class:WebActionMapper +WebPage webview.h /^class WebPage : public QWebPage $/;" c ln:39 +WebPage webview.cpp /^WebPage::WebPage(QObject *parent)$/;" f ln:42 class:WebPage +WebView browsermainwindow.h /^class WebView;$/;" v ln:41 +WebView tabwidget.h /^class WebView;$/;" v ln:78 +WebView webview.h /^class WebView : public QWebView $/;" c ln:70 +WebView webview.cpp /^WebView::WebView(QWidget* parent)$/;" f ln:171 class:WebView +aboutToShowRecentTabsMenu tabwidget.cpp /^void TabWidget::aboutToShowRecentTabsMenu()$/;" f ln:678 class:TabWidget +aboutToShowRecentTriggeredAction tabwidget.cpp /^void TabWidget::aboutToShowRecentTriggeredAction(QAction *action)$/;" f ln:693 class:TabWidget +acceptNavigationRequest webview.cpp /^bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)$/;" f ln:65 class:WebPage +acceptPolicy cookiejar.cpp /^CookieJar::AcceptPolicy CookieJar::acceptPolicy() const$/;" f ln:301 class:CookieJar +activated history.cpp /^void HistoryMenu::activated(const QModelIndex &index)$/;" f ln:623 class:HistoryMenu +activeDownloads downloadmanager.cpp /^int DownloadManager::activeDownloads() const$/;" f ln:334 class:DownloadManager +addChild tabwidget.cpp /^void WebActionMapper::addChild(KAction *action)$/;" f ln:860 class:WebActionMapper +addHistoryEntry history.cpp /^void HistoryManager::addHistoryEntry(const QString &url)$/;" f ln:83 class:HistoryManager +addHistoryItem history.cpp /^void HistoryManager::addHistoryItem(const HistoryItem &item)$/;" f ln:161 class:HistoryManager +addItem downloadmanager.cpp /^void DownloadManager::addItem(DownloadItem *item)$/;" f ln:366 class:DownloadManager +addWebAction tabwidget.cpp /^void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction)$/;" f ln:319 class:TabWidget +allow cookiejar.cpp /^void CookiesExceptionsDialog::allow()$/;" f ln:766 class:CookiesExceptionsDialog +allowForSession cookiejar.cpp /^void CookiesExceptionsDialog::allowForSession()$/;" f ln:775 class:CookiesExceptionsDialog +allowForSessionCookies cookiejar.cpp /^QStringList CookieJar::allowForSessionCookies() const$/;" f ln:361 class:CookieJar +allowedCookies cookiejar.cpp /^QStringList CookieJar::allowedCookies() const$/;" f ln:352 class:CookieJar +authenticationRequired networkaccessmanager.cpp /^void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth)$/;" f ln:84 class:NetworkAccessManager +block cookiejar.cpp /^void CookiesExceptionsDialog::block()$/;" f ln:757 class:CookiesExceptionsDialog +blockedCookies cookiejar.cpp /^QStringList CookieJar::blockedCookies() const$/;" f ln:343 class:CookieJar +bumpedRows history.cpp /^int HistoryMenuModel::bumpedRows() const$/;" f ln:506 class:HistoryMenuModel +canRestoreSession browserapplication.cpp /^bool BrowserApplication::canRestoreSession() const$/;" f ln:227 class:BrowserApplication +changeOccurred autosaver.cpp /^void AutoSaver::changeOccurred()$/;" f ln:42 class:AutoSaver +checkForExpired history.cpp /^void HistoryManager::checkForExpired()$/;" f ln:131 class:HistoryManager +childChanged tabwidget.cpp /^void WebActionMapper::childChanged()$/;" f ln:883 class:WebActionMapper +chooseFixedFont settings.cpp /^void SettingsDialog::chooseFixedFont()$/;" f ln:293 class:SettingsDialog +chooseFont settings.cpp /^void SettingsDialog::chooseFont()$/;" f ln:281 class:SettingsDialog +clean browserapplication.cpp /^void BrowserApplication::clean()$/;" f ln:189 class:BrowserApplication +cleanup downloadmanager.cpp /^void DownloadManager::cleanup()$/;" f ln:487 class:DownloadManager +clear cookiejar.cpp /^void CookieJar::clear()$/;" f ln:94 class:CookieJar +clear findbar.cpp /^void FindBar::clear()$/;" f ln:71 class:FindBar +clear history.cpp /^void HistoryManager::clear()$/;" f ln:208 class:HistoryManager +clear tabwidget.cpp /^void TabWidget::clear()$/;" f ln:274 class:TabWidget +cloneTab tabwidget.cpp /^void TabBar::cloneTab()$/;" f ln:100 class:TabBar +cloneTab tabwidget.cpp /^void TabWidget::cloneTab(int index)$/;" f ln:576 class:TabWidget +closeEvent browsermainwindow.cpp /^void BrowserMainWindow::closeEvent(QCloseEvent *event)$/;" f ln:655 class:BrowserMainWindow +closeOtherTabs tabwidget.cpp /^void TabBar::closeOtherTabs()$/;" f ln:120 class:TabBar +closeOtherTabs tabwidget.cpp /^void TabWidget::closeOtherTabs(int index)$/;" f ln:564 class:TabWidget +closeTab tabwidget.cpp /^void TabBar::closeTab()$/;" f ln:110 class:TabBar +closeTab tabwidget.cpp /^void TabWidget::closeTab(int index)$/;" f ln:588 class:TabWidget +closeTabAction tabwidget.cpp /^KAction *TabWidget::closeTabAction() const$/;" f ln:375 class:TabWidget +columnCount cookiejar.cpp /^int CookieModel::columnCount(const QModelIndex &parent) const$/;" f ln:487 class:CookieModel +columnCount cookiejar.cpp /^int CookieExceptionsModel::columnCount(const QModelIndex &parent) const$/;" f ln:651 class:CookieExceptionsModel +columnCount history.cpp /^int HistoryModel::columnCount(const QModelIndex &parent) const$/;" f ln:462 class:HistoryModel +columnCount history.cpp /^int HistoryMenuModel::columnCount(const QModelIndex &parent) const$/;" f ln:514 class:HistoryMenuModel +columnCount history.cpp /^int HistoryFilterModel::columnCount(const QModelIndex &parent) const$/;" f ln:845 class:HistoryFilterModel +columnCount history.cpp /^int HistoryCompletionModel::columnCount(const QModelIndex &parent) const$/;" f ln:1014 class:HistoryCompletionModel +columnCount history.cpp /^int HistoryTreeModel::columnCount(const QModelIndex &parent) const$/;" f ln:1127 class:HistoryTreeModel +contextMenuEvent tabwidget.cpp /^void TabWidget::contextMenuEvent(QContextMenuEvent *event)$/;" f ln:713 class:TabWidget +contextMenuEvent webview.cpp /^void WebView::contextMenuEvent(QContextMenuEvent *event)$/;" f ln:187 class:WebView +contextMenuRequested tabwidget.cpp /^void TabBar::contextMenuRequested(const QPoint &position)$/;" f ln:68 class:TabBar +cookieJar browserapplication.cpp /^CookieJar *BrowserApplication::cookieJar()$/;" f ln:328 class:BrowserApplication +cookiesChanged cookiejar.cpp /^void CookieModel::cookiesChanged()$/;" f ln:512 class:CookieModel +cookiesForUrl cookiejar.cpp /^QList CookieJar::cookiesForUrl(const QUrl &url) const$/;" f ln:221 class:CookieJar +copy history.cpp /^void HistoryDialog::copy()$/;" f ln:753 class:HistoryDialog +createMenu modelmenu.cpp /^void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu, QMenu *menu)$/;" f ln:145 class:ModelMenu +createWindow webview.cpp /^QWebPage *WebPage::createWindow(QWebPage::WebWindowType type)$/;" f ln:103 class:WebPage +currentChanged tabwidget.cpp /^void TabWidget::currentChanged(int index)$/;" f ln:327 class:TabWidget +currentDestroyed tabwidget.cpp /^void WebActionMapper::currentDestroyed()$/;" f ln:854 class:WebActionMapper +currentLineEdit tabwidget.cpp /^KLineEdit *TabWidget::currentLineEdit() const$/;" f ln:405 class:TabWidget +currentTab browsermainwindow.cpp /^WebView *BrowserMainWindow::currentTab() const$/;" f ln:852 class:BrowserMainWindow +currentTitle bookmarks.cpp /^QString OwnBookMarks::currentTitle() const$/;" f ln:51 class:OwnBookMarks +currentUrl bookmarks.cpp /^QString OwnBookMarks::currentUrl() const$/;" f ln:44 class:OwnBookMarks +currentWebView tabwidget.cpp /^WebView *TabWidget::currentWebView() const$/;" f ln:411 class:TabWidget +customContextMenuRequested history.cpp /^void HistoryDialog::customContextMenuRequested(const QPoint &pos)$/;" f ln:729 class:HistoryDialog +data cookiejar.cpp /^QVariant CookieModel::data(const QModelIndex &index, int role) const$/;" f ln:450 class:CookieModel +data cookiejar.cpp /^QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const$/;" f ln:606 class:CookieExceptionsModel +data downloadmanager.cpp /^QVariant DownloadModel::data(const QModelIndex &index, int role) const$/;" f ln:512 class:DownloadModel +data history.cpp /^QVariant HistoryModel::data(const QModelIndex &index, int role) const$/;" f ln:420 class:HistoryModel +data history.cpp /^QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const$/;" f ln:784 class:HistoryFilterModel +data history.cpp /^QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const$/;" f ln:987 class:HistoryCompletionModel +data history.cpp /^QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const$/;" f ln:1097 class:HistoryTreeModel +dataString downloadmanager.cpp /^QString DownloadItem::dataString(int size) const$/;" f ln:266 class:DownloadItem +download downloadmanager.cpp /^void DownloadManager::download(const QNetworkRequest &request, bool requestFileName)$/;" f ln:344 class:DownloadManager +downloadManager browserapplication.cpp /^DownloadManager *BrowserApplication::downloadManager()$/;" f ln:334 class:BrowserApplication +downloadProgress downloadmanager.cpp /^void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)$/;" f ln:216 class:DownloadItem +downloadReadyRead downloadmanager.cpp /^void DownloadItem::downloadReadyRead()$/;" f ln:181 class:DownloadItem +downloadRequested webview.cpp /^void WebView::downloadRequested(const QNetworkRequest &request)$/;" f ln:299 class:WebView +downloadedSuccessfully downloadmanager.cpp /^bool DownloadItem::downloadedSuccessfully() const$/;" f ln:286 class:DownloadItem +downloading downloadmanager.cpp /^bool DownloadItem::downloading() const$/;" f ln:281 class:DownloadItem +dragEnterEvent tabwidget.cpp /^void TabBar::dragEnterEvent(QDragEnterEvent *event)$/;" f ln:158 class:TabBar +dropEvent tabwidget.cpp /^void TabBar::dropEvent(QDropEvent *event)$/;" f ln:171 class:TabBar +entryAdded history.cpp /^void HistoryModel::entryAdded()$/;" f ln:391 class:HistoryModel +entryUpdated history.cpp /^void HistoryModel::entryUpdated(int offset)$/;" f ln:398 class:HistoryModel +error downloadmanager.cpp /^void DownloadItem::error(QNetworkReply::NetworkError)$/;" f ln:203 class:DownloadItem +filterAcceptsRow history.cpp /^bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const$/;" f ln:688 class:TreeProxyModel +finished downloadmanager.cpp /^void DownloadItem::finished()$/;" f ln:291 class:DownloadItem +firstSeparator modelmenu.cpp /^int ModelMenu::firstSeparator() const$/;" f ln:78 class:ModelMenu +flags history.cpp /^Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const$/;" f ln:1226 class:HistoryTreeModel +generateGradient urlbar.cpp /^QLinearGradient UrlBar::generateGradient(const QColor &color) const$/;" f ln:97 class:UrlBar +geometryChangeRequested browsermainwindow.cpp /^void BrowserMainWindow::geometryChangeRequested(const QRect &geometry)$/;" f ln:977 class:BrowserMainWindow +getFileName downloadmanager.cpp /^void DownloadItem::getFileName()$/;" f ln:93 class:DownloadItem +guessUrlFromString browsermainwindow.cpp /^KUrl BrowserMainWindow::guessUrlFromString(const QString &string)$/;" f ln:443 class:BrowserMainWindow +handleUnsupportedContent downloadmanager.cpp /^void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool requestFileName)$/;" f ln:351 class:DownloadManager +handleUnsupportedContent webview.cpp /^void WebPage::handleUnsupportedContent(QNetworkReply *reply)$/;" f ln:119 class:WebPage +hasChildren history.cpp /^bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const$/;" f ln:1217 class:HistoryTreeModel +headerData cookiejar.cpp /^QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:415 class:CookieModel +headerData cookiejar.cpp /^QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:583 class:CookieExceptionsModel +headerData history.cpp /^QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:405 class:HistoryModel +headerData history.cpp /^QVariant HistoryFilterModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:823 class:HistoryFilterModel +headerData history.cpp /^QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:1091 class:HistoryTreeModel +history history.cpp /^QList HistoryManager::history() const$/;" f ln:71 class:HistoryManager +historyContains history.cpp /^bool HistoryManager::historyContains(const QString &url) const$/;" f ln:77 class:HistoryManager +historyFilterModel history.cpp /^HistoryFilterModel *HistoryManager::historyFilterModel() const$/;" f ln:119 class:HistoryManager +historyLimit history.cpp /^int HistoryManager::historyLimit() const$/;" f ln:192 class:HistoryManager +historyLocation history.cpp /^int HistoryFilterModel::historyLocation(const QString &url) const$/;" f ln:775 class:HistoryFilterModel +historyManager browserapplication.cpp /^HistoryManager *BrowserApplication::historyManager()$/;" f ln:357 class:BrowserApplication +historyModel history.cpp /^HistoryModel *HistoryManager::historyModel() const$/;" f ln:113 class:HistoryManager +historyReset history.cpp /^void HistoryModel::historyReset()$/;" f ln:385 class:HistoryModel +historyTreeModel history.cpp /^HistoryTreeModel *HistoryManager::historyTreeModel() const$/;" f ln:125 class:HistoryManager +hoverRole modelmenu.cpp /^int ModelMenu::hoverRole() const$/;" f ln:102 class:ModelMenu +hovered modelmenu.cpp /^void ModelMenu::hovered(QAction *action)$/;" f ln:213 class:ModelMenu +icon browserapplication.cpp /^KIcon BrowserApplication::icon(const KUrl &url) const$/;" f ln:370 class:BrowserApplication +index history.cpp /^QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:572 class:HistoryMenuModel +index history.cpp /^QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:886 class:HistoryFilterModel +index history.cpp /^QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:1036 class:HistoryCompletionModel +index history.cpp /^QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:1195 class:HistoryTreeModel +init downloadmanager.cpp /^void DownloadItem::init()$/;" f ln:65 class:DownloadItem +instance browserapplication.cpp /^BrowserApplication *BrowserApplication::instance()$/;" f ln:110 class:BrowserApplication +isTheOnlyBrowser browserapplication.cpp /^bool BrowserApplication::isTheOnlyBrowser() const$/;" f ln:266 class:BrowserApplication +keepPolicy cookiejar.cpp /^CookieJar::KeepPolicy CookieJar::keepPolicy() const$/;" f ln:322 class:CookieJar +keyPressEvent edittableview.cpp /^void EditTableView::keyPressEvent(QKeyEvent *event)$/;" f ln:29 class:EditTableView +keyPressEvent edittreeview.cpp /^void EditTreeView::keyPressEvent(QKeyEvent *event)$/;" f ln:30 class:EditTreeView +keyPressEvent findbar.cpp /^void FindBar::keyPressEvent(QKeyEvent* event)$/;" f ln:88 class:FindBar +lastStatusBarText webview.cpp /^QString WebView::lastStatusBarText() const$/;" f ln:254 class:WebView +lineEdit findbar.cpp /^KLineEdit *FindBar::lineEdit()$/;" f ln:65 class:FindBar +lineEdit searchbar.cpp /^KLineEdit *SearchBar::lineEdit()$/;" f ln:58 class:SearchBar +lineEdit tabwidget.cpp /^KLineEdit *TabWidget::lineEdit(int index) const$/;" f ln:417 class:TabWidget +lineEdit urlbar.cpp /^KLineEdit *UrlBar::lineEdit()$/;" f ln:63 class:UrlBar +lineEditReturnPressed tabwidget.cpp /^void TabWidget::lineEditReturnPressed()$/;" f ln:538 class:TabWidget +lineEditStack tabwidget.cpp /^QWidget *TabWidget::lineEditStack() const$/;" f ln:399 class:TabWidget +load cookiejar.cpp /^void CookieJar::load()$/;" f ln:101 class:CookieJar +load downloadmanager.cpp /^void DownloadManager::load()$/;" f ln:451 class:DownloadManager +load history.cpp /^void HistoryManager::load()$/;" f ln:228 class:HistoryManager +load history.cpp /^void HistoryFilterModel::load() const$/;" f ln:903 class:HistoryFilterModel +loadDefaultState browsermainwindow.cpp /^void BrowserMainWindow::loadDefaultState()$/;" f ln:119 class:BrowserMainWindow +loadDefaults settings.cpp /^void SettingsDialog::loadDefaults()$/;" f ln:70 class:SettingsDialog +loadFinished webview.cpp /^void WebView::loadFinished()$/;" f ln:236 class:WebView +loadFromSettings settings.cpp /^void SettingsDialog::loadFromSettings()$/;" f ln:90 class:SettingsDialog +loadPage browsermainwindow.cpp /^void BrowserMainWindow::loadPage(const QString &page)$/;" f ln:832 class:BrowserMainWindow +loadSettings browserapplication.cpp /^void BrowserApplication::loadSettings()$/;" f ln:146 class:BrowserApplication +loadSettings cookiejar.cpp /^void CookieJar::loadSettings()$/;" f ln:133 class:CookieJar +loadSettings history.cpp /^void HistoryManager::loadSettings()$/;" f ln:218 class:HistoryManager +loadSettings networkaccessmanager.cpp /^void NetworkAccessManager::loadSettings()$/;" f ln:58 class:NetworkAccessManager +loadUrl browsermainwindow.cpp /^void BrowserMainWindow::loadUrl(const KUrl &url)$/;" f ln:500 class:BrowserMainWindow +loadUrl webview.cpp /^void WebView::loadUrl(const KUrl &url)$/;" f ln:247 class:WebView +loadUrlInCurrentTab tabwidget.cpp /^void TabWidget::loadUrlInCurrentTab(const KUrl &url)$/;" f ln:739 class:TabWidget +main main.cpp /^int main(int argc, char **argv)$/;" f ln:29 +mainWindow browserapplication.cpp /^BrowserMainWindow *BrowserApplication::mainWindow()$/;" f ln:288 class:BrowserApplication +mainWindow webview.cpp /^BrowserMainWindow *WebPage::mainWindow()$/;" f ln:53 class:WebPage +mainWindows browserapplication.cpp /^QList BrowserApplication::mainWindows()$/;" f ln:175 class:BrowserApplication +makeAction modelmenu.cpp /^KAction *ModelMenu::makeAction(const QModelIndex &index)$/;" f ln:184 class:ModelMenu +makeAction modelmenu.cpp /^KAction *ModelMenu::makeAction(const KIcon &icon, const QString &text, QObject *parent)$/;" f ln:194 class:ModelMenu +mapFromSource history.cpp /^QModelIndex HistoryMenuModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:545 class:HistoryMenuModel +mapFromSource history.cpp /^QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:859 class:HistoryFilterModel +mapFromSource history.cpp /^QModelIndex HistoryCompletionModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:1020 class:HistoryCompletionModel +mapFromSource history.cpp /^QModelIndex HistoryTreeModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:1312 class:HistoryTreeModel +mapToSource history.cpp /^QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:553 class:HistoryMenuModel +mapToSource history.cpp /^QModelIndex HistoryFilterModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:851 class:HistoryFilterModel +mapToSource history.cpp /^QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:1027 class:HistoryCompletionModel +mapToSource history.cpp /^QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:1185 class:HistoryTreeModel +maxRows modelmenu.cpp /^int ModelMenu::maxRows() const$/;" f ln:66 class:ModelMenu +metaDataChanged downloadmanager.cpp /^void DownloadItem::metaDataChanged()$/;" f ln:211 class:DownloadItem +model modelmenu.cpp /^QAbstractItemModel *ModelMenu::model() const$/;" f ln:54 class:ModelMenu +mouseDoubleClickEvent tabwidget.cpp /^void TabWidget::mouseDoubleClickEvent(QMouseEvent *event)$/;" f ln:700 class:TabWidget +mouseMoveEvent tabwidget.cpp /^void TabBar::mouseMoveEvent(QMouseEvent *event)$/;" f ln:138 class:TabBar +mousePressEvent tabwidget.cpp /^void TabBar::mousePressEvent(QMouseEvent *event)$/;" f ln:130 class:TabBar +mousePressEvent webview.cpp /^void WebView::mousePressEvent(QMouseEvent *event)$/;" f ln:271 class:WebView +mouseReleaseEvent tabwidget.cpp /^void TabWidget::mouseReleaseEvent(QMouseEvent *event)$/;" f ln:723 class:TabWidget +mouseReleaseEvent webview.cpp /^void WebView::mouseReleaseEvent(QMouseEvent *event)$/;" f ln:279 class:WebView +moveTab tabwidget.cpp /^void TabWidget::moveTab(int fromIndex, int toIndex)$/;" f ln:287 class:TabWidget +networkAccessManager browserapplication.cpp /^NetworkAccessManager *BrowserApplication::networkAccessManager()$/;" f ln:345 class:BrowserApplication +newLocalSocketConnection browserapplication.cpp /^void BrowserApplication::newLocalSocketConnection()$/;" f ln:297 class:BrowserApplication +newMainWindow browserapplication.cpp /^BrowserMainWindow *BrowserApplication::newMainWindow()$/;" f ln:279 class:BrowserApplication +newTab tabwidget.cpp /^WebView *TabWidget::newTab(bool makeCurrent)$/;" f ln:457 class:TabWidget +newTabAction tabwidget.cpp /^KAction *TabWidget::newTabAction() const$/;" f ln:369 class:TabWidget +nextTab tabwidget.cpp /^void TabWidget::nextTab()$/;" f ln:750 class:TabWidget +nextTabAction tabwidget.cpp /^KAction *TabWidget::nextTabAction() const$/;" f ln:387 class:TabWidget +open downloadmanager.cpp /^void DownloadItem::open()$/;" f ln:153 class:DownloadItem +open history.cpp /^void HistoryDialog::open()$/;" f ln:744 class:HistoryDialog +openBookmark bookmarks.cpp /^void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons , Qt::KeyboardModifiers )$/;" f ln:39 class:OwnBookMarks +openLinkInNewTab webview.cpp /^void WebView::openLinkInNewTab()$/;" f ln:223 class:WebView +openUrl browserapplication.cpp /^void BrowserApplication::openUrl(const KUrl &url)$/;" f ln:272 class:BrowserApplication +operator<< cookiejar.cpp /^QDataStream &operator<<(QDataStream &stream, const QList &list)$/;" f ln:40 +operator>> cookiejar.cpp /^QDataStream &operator>>(QDataStream &stream, QList &list)$/;" f ln:49 +paintEvent squeezelabel.cpp /^void SqueezeLabel::paintEvent(QPaintEvent *event)$/;" f ln:27 class:SqueezeLabel +parent history.cpp /^QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const$/;" f ln:594 class:HistoryMenuModel +parent history.cpp /^QModelIndex HistoryFilterModel::parent(const QModelIndex &) const$/;" f ln:897 class:HistoryFilterModel +parent history.cpp /^QModelIndex HistoryCompletionModel::parent(const QModelIndex &) const$/;" f ln:1045 class:HistoryCompletionModel +parent history.cpp /^QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const$/;" f ln:1208 class:HistoryTreeModel +postLaunch browserapplication.cpp /^void BrowserApplication::postLaunch()$/;" f ln:119 class:BrowserApplication +postPopulated history.cpp /^void HistoryMenu::postPopulated()$/;" f ln:648 class:HistoryMenu +postPopulated modelmenu.cpp /^void ModelMenu::postPopulated()$/;" f ln:43 class:ModelMenu +prePopulated history.cpp /^bool HistoryMenu::prePopulated()$/;" f ln:629 class:HistoryMenu +prePopulated modelmenu.cpp /^bool ModelMenu::prePopulated()$/;" f ln:37 class:ModelMenu +previousTab tabwidget.cpp /^void TabWidget::previousTab()$/;" f ln:759 class:TabWidget +previousTabAction tabwidget.cpp /^KAction *TabWidget::previousTabAction() const$/;" f ln:393 class:TabWidget +printRequested browsermainwindow.cpp /^void BrowserMainWindow::printRequested(QWebFrame *frame)$/;" f ln:603 class:BrowserMainWindow +proxyAuthenticationRequired networkaccessmanager.cpp /^void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)$/;" f ln:108 class:NetworkAccessManager +purgeOldCookies cookiejar.cpp /^void CookieJar::purgeOldCookies()$/;" f ln:203 class:CookieJar +recentlyClosedTabsAction tabwidget.cpp /^KAction *TabWidget::recentlyClosedTabsAction() const$/;" f ln:381 class:TabWidget +reloadAllTabs tabwidget.cpp /^void TabWidget::reloadAllTabs()$/;" f ln:525 class:TabWidget +reloadTab tabwidget.cpp /^void TabBar::reloadTab()$/;" f ln:184 class:TabBar +reloadTab tabwidget.cpp /^void TabWidget::reloadTab(int index)$/;" f ln:305 class:TabWidget +removeAll edittableview.cpp /^void EditTableView::removeAll()$/;" f ln:52 class:EditTableView +removeAll edittreeview.cpp /^void EditTreeView::removeAll()$/;" f ln:50 class:EditTreeView +removeOne edittableview.cpp /^void EditTableView::removeOne()$/;" f ln:40 class:EditTableView +removeOne edittreeview.cpp /^void EditTreeView::removeOne()$/;" f ln:41 class:EditTreeView +removePolicy downloadmanager.cpp /^DownloadManager::RemovePolicy DownloadManager::removePolicy() const$/;" f ln:412 class:DownloadManager +removeRows cookiejar.cpp /^bool CookieModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:497 class:CookieModel +removeRows cookiejar.cpp /^bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:661 class:CookieExceptionsModel +removeRows downloadmanager.cpp /^bool DownloadModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:527 class:DownloadModel +removeRows history.cpp /^bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:474 class:HistoryModel +removeRows history.cpp /^bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:959 class:HistoryFilterModel +removeRows history.cpp /^bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:1234 class:HistoryTreeModel +restoreLastSession browserapplication.cpp /^void BrowserApplication::restoreLastSession()$/;" f ln:233 class:BrowserApplication +restoreState browsermainwindow.cpp /^bool BrowserMainWindow::restoreState(const QByteArray &state)$/;" f ln:174 class:BrowserMainWindow +restoreState tabwidget.cpp /^bool TabWidget::restoreState(const QByteArray &state)$/;" f ln:798 class:TabWidget +rootDestroyed tabwidget.cpp /^void WebActionMapper::rootDestroyed()$/;" f ln:848 class:WebActionMapper +rootIndex modelmenu.cpp /^QModelIndex ModelMenu::rootIndex() const$/;" f ln:90 class:ModelMenu +rootTriggered tabwidget.cpp /^void WebActionMapper::rootTriggered()$/;" f ln:873 class:WebActionMapper +rowCount cookiejar.cpp /^int CookieModel::rowCount(const QModelIndex &parent) const$/;" f ln:492 class:CookieModel +rowCount cookiejar.cpp /^int CookieExceptionsModel::rowCount(const QModelIndex &parent) const$/;" f ln:656 class:CookieExceptionsModel +rowCount downloadmanager.cpp /^int DownloadModel::rowCount(const QModelIndex &parent) const$/;" f ln:522 class:DownloadModel +rowCount history.cpp /^int HistoryModel::rowCount(const QModelIndex &parent) const$/;" f ln:468 class:HistoryModel +rowCount history.cpp /^int HistoryMenuModel::rowCount(const QModelIndex &parent) const$/;" f ln:519 class:HistoryMenuModel +rowCount history.cpp /^int HistoryFilterModel::rowCount(const QModelIndex &parent) const$/;" f ln:836 class:HistoryFilterModel +rowCount history.cpp /^int HistoryCompletionModel::rowCount(const QModelIndex &parent) const$/;" f ln:1008 class:HistoryCompletionModel +rowCount history.cpp /^int HistoryTreeModel::rowCount(const QModelIndex &parent) const$/;" f ln:1133 class:HistoryTreeModel +s_downloadManager browserapplication.cpp /^DownloadManager *BrowserApplication::s_downloadManager = 0;$/;" v ln:52 class:BrowserApplication +s_historyManager browserapplication.cpp /^HistoryManager *BrowserApplication::s_historyManager = 0;$/;" v ln:53 class:BrowserApplication +s_networkAccessManager browserapplication.cpp /^NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0;$/;" v ln:54 class:BrowserApplication +save browsermainwindow.cpp /^void BrowserMainWindow::save()$/;" f ln:138 class:BrowserMainWindow +save cookiejar.cpp /^void CookieJar::save()$/;" f ln:156 class:CookieJar +save downloadmanager.cpp /^void DownloadManager::save() const$/;" f ln:425 class:DownloadManager +save history.cpp /^void HistoryManager::save()$/;" f ln:296 class:HistoryManager +saveFileName downloadmanager.cpp /^QString DownloadItem::saveFileName(const QString &directory) const$/;" f ln:118 class:DownloadItem +saveIfNeccessary autosaver.cpp /^void AutoSaver::saveIfNeccessary()$/;" f ln:63 class:AutoSaver +saveSession browserapplication.cpp /^void BrowserApplication::saveSession()$/;" f ln:202 class:BrowserApplication +saveState browsermainwindow.cpp /^QByteArray BrowserMainWindow::saveState(bool withTabs) const$/;" f ln:154 class:BrowserMainWindow +saveState tabwidget.cpp /^QByteArray TabWidget::saveState() const$/;" f ln:771 class:TabWidget +saveToSettings settings.cpp /^void SettingsDialog::saveToSettings()$/;" f ln:182 class:SettingsDialog +searchNow searchbar.cpp /^void SearchBar::searchNow()$/;" f ln:45 class:SearchBar +selectTabAction tabwidget.cpp /^void TabBar::selectTabAction()$/;" f ln:56 class:TabBar +separatorRole modelmenu.cpp /^int ModelMenu::separatorRole() const$/;" f ln:114 class:ModelMenu +setAcceptPolicy cookiejar.cpp /^void CookieJar::setAcceptPolicy(AcceptPolicy policy)$/;" f ln:310 class:CookieJar +setAllowForSessionCookies cookiejar.cpp /^void CookieJar::setAllowForSessionCookies(const QStringList &list)$/;" f ln:392 class:CookieJar +setAllowedCookies cookiejar.cpp /^void CookieJar::setAllowedCookies(const QStringList &list)$/;" f ln:381 class:CookieJar +setBlockedCookies cookiejar.cpp /^void CookieJar::setBlockedCookies(const QStringList &list)$/;" f ln:370 class:CookieJar +setCookiesFromUrl cookiejar.cpp /^bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url)$/;" f ln:237 class:CookieJar +setFirstSeparator modelmenu.cpp /^void ModelMenu::setFirstSeparator(int offset)$/;" f ln:72 class:ModelMenu +setHistory history.cpp /^void HistoryManager::setHistory(const QList &history, bool loadedAndSorted)$/;" f ln:93 class:HistoryManager +setHistoryLimit history.cpp /^void HistoryManager::setHistoryLimit(int limit)$/;" f ln:198 class:HistoryManager +setHomeToCurrentPage settings.cpp /^void SettingsDialog::setHomeToCurrentPage()$/;" f ln:306 class:SettingsDialog +setHoverRole modelmenu.cpp /^void ModelMenu::setHoverRole(int role)$/;" f ln:96 class:ModelMenu +setInitialActions history.cpp /^void HistoryMenu::setInitialActions(QList actions)$/;" f ln:671 class:HistoryMenu +setKeepPolicy cookiejar.cpp /^void CookieJar::setKeepPolicy(KeepPolicy policy)$/;" f ln:331 class:CookieJar +setMaxRows modelmenu.cpp /^void ModelMenu::setMaxRows(int max)$/;" f ln:60 class:ModelMenu +setModel modelmenu.cpp /^void ModelMenu::setModel(QAbstractItemModel *model)$/;" f ln:48 class:ModelMenu +setProgress webview.cpp /^void WebView::setProgress(int progress)$/;" f ln:230 class:WebView +setRemovePolicy downloadmanager.cpp /^void DownloadManager::setRemovePolicy(RemovePolicy policy)$/;" f ln:417 class:DownloadManager +setRootIndex modelmenu.cpp /^void ModelMenu::setRootIndex(const QModelIndex &index)$/;" f ln:84 class:ModelMenu +setSeparatorRole modelmenu.cpp /^void ModelMenu::setSeparatorRole(int role)$/;" f ln:108 class:ModelMenu +setSourceModel history.cpp /^void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel)$/;" f ln:790 class:HistoryFilterModel +setSourceModel history.cpp /^void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel)$/;" f ln:1051 class:HistoryCompletionModel +setSourceModel history.cpp /^void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel)$/;" f ln:1256 class:HistoryTreeModel +setStatusBarText webview.cpp /^void WebView::setStatusBarText(const QString &string)$/;" f ln:293 class:WebView +setWebView urlbar.cpp /^void UrlBar::setWebView(WebView *webView)$/;" f ln:69 class:UrlBar +setupMenu browsermainwindow.cpp /^void BrowserMainWindow::setupMenu()$/;" f ln:214 class:BrowserMainWindow +setupToolBar browsermainwindow.cpp /^void BrowserMainWindow::setupToolBar()$/;" f ln:373 class:BrowserMainWindow +showCookies settings.cpp /^void SettingsDialog::showCookies()$/;" f ln:267 class:SettingsDialog +showExceptions settings.cpp /^void SettingsDialog::showExceptions()$/;" f ln:274 class:SettingsDialog +showFindBar findbar.cpp /^void FindBar::showFindBar()$/;" f ln:77 class:FindBar +showHistoryDialog history.cpp /^void HistoryMenu::showHistoryDialog()$/;" f ln:663 class:HistoryMenu +sizeHint browsermainwindow.cpp /^QSize BrowserMainWindow::sizeHint() const$/;" f ln:129 class:BrowserMainWindow +slotAboutToShowBackMenu browsermainwindow.cpp /^void BrowserMainWindow::slotAboutToShowBackMenu()$/;" f ln:881 class:BrowserMainWindow +slotAboutToShowWindowMenu browsermainwindow.cpp /^void BrowserMainWindow::slotAboutToShowWindowMenu()$/;" f ln:902 class:BrowserMainWindow +slotAddBookmark browsermainwindow.cpp /^void BrowserMainWindow::slotAddBookmark()$/;" f ln:410 class:BrowserMainWindow +slotApply settings.cpp /^void SettingsDialog::slotApply()$/;" f ln:323 class:SettingsDialog +slotDownloadManager browsermainwindow.cpp /^void BrowserMainWindow::slotDownloadManager()$/;" f ln:508 class:BrowserMainWindow +slotFileNew browsermainwindow.cpp /^void BrowserMainWindow::slotFileNew()$/;" f ln:559 class:BrowserMainWindow +slotFileOpen browsermainwindow.cpp /^void BrowserMainWindow::slotFileOpen()$/;" f ln:569 class:BrowserMainWindow +slotFilePrint browsermainwindow.cpp /^void BrowserMainWindow::slotFilePrint()$/;" f ln:594 class:BrowserMainWindow +slotFilePrintPreview browsermainwindow.cpp /^void BrowserMainWindow::slotFilePrintPreview()$/;" f ln:583 class:BrowserMainWindow +slotFileSaveAs browsermainwindow.cpp /^void BrowserMainWindow::slotFileSaveAs()$/;" f ln:523 class:BrowserMainWindow +slotFind browsermainwindow.cpp /^void BrowserMainWindow::slotFind(const QString & search)$/;" f ln:675 class:BrowserMainWindow +slotFindNext browsermainwindow.cpp /^void BrowserMainWindow::slotFindNext()$/;" f ln:694 class:BrowserMainWindow +slotFindPrevious browsermainwindow.cpp /^void BrowserMainWindow::slotFindPrevious()$/;" f ln:702 class:BrowserMainWindow +slotHome browsermainwindow.cpp /^void BrowserMainWindow::slotHome()$/;" f ln:783 class:BrowserMainWindow +slotLoadProgress browsermainwindow.cpp /^void BrowserMainWindow::slotLoadProgress(int progress)$/;" f ln:858 class:BrowserMainWindow +slotOk settings.cpp /^void SettingsDialog::slotOk()$/;" f ln:317 class:SettingsDialog +slotOpenActionUrl browsermainwindow.cpp /^void BrowserMainWindow::slotOpenActionUrl(QAction *action)$/;" f ln:944 class:BrowserMainWindow +slotOpenNext browsermainwindow.cpp /^void BrowserMainWindow::slotOpenNext()$/;" f ln:970 class:BrowserMainWindow +slotOpenPrevious browsermainwindow.cpp /^void BrowserMainWindow::slotOpenPrevious()$/;" f ln:962 class:BrowserMainWindow +slotPreferences browsermainwindow.cpp /^void BrowserMainWindow::slotPreferences()$/;" f ln:531 class:BrowserMainWindow +slotPrivateBrowsing browsermainwindow.cpp /^void BrowserMainWindow::slotPrivateBrowsing()$/;" f ln:615 class:BrowserMainWindow +slotSelectLineEdit browsermainwindow.cpp /^void BrowserMainWindow::slotSelectLineEdit()$/;" f ln:515 class:BrowserMainWindow +slotShowWindow browsermainwindow.cpp /^void BrowserMainWindow::slotShowWindow()$/;" f ln:926 class:BrowserMainWindow +slotSwapFocus browsermainwindow.cpp /^void BrowserMainWindow::slotSwapFocus()$/;" f ln:822 class:BrowserMainWindow +slotToggleInspector browsermainwindow.cpp /^void BrowserMainWindow::slotToggleInspector(bool enable)$/;" f ln:803 class:BrowserMainWindow +slotUpdateStatusbar browsermainwindow.cpp /^void BrowserMainWindow::slotUpdateStatusbar(const QString &string)$/;" f ln:540 class:BrowserMainWindow +slotUpdateWindowTitle browsermainwindow.cpp /^void BrowserMainWindow::slotUpdateWindowTitle(const QString &title)$/;" f ln:548 class:BrowserMainWindow +slotViewFindBar browsermainwindow.cpp /^void BrowserMainWindow::slotViewFindBar()$/;" f ln:688 class:BrowserMainWindow +slotViewFullScreen browsermainwindow.cpp /^void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen)$/;" f ln:739 class:BrowserMainWindow +slotViewPageSource browsermainwindow.cpp /^void BrowserMainWindow::slotViewPageSource()$/;" f ln:768 class:BrowserMainWindow +slotViewStatusbar browsermainwindow.cpp /^void BrowserMainWindow::slotViewStatusbar()$/;" f ln:428 class:BrowserMainWindow +slotViewTextBigger browsermainwindow.cpp /^void BrowserMainWindow::slotViewTextBigger()$/;" f ln:711 class:BrowserMainWindow +slotViewTextNormal browsermainwindow.cpp /^void BrowserMainWindow::slotViewTextNormal()$/;" f ln:720 class:BrowserMainWindow +slotViewTextSmaller browsermainwindow.cpp /^void BrowserMainWindow::slotViewTextSmaller()$/;" f ln:729 class:BrowserMainWindow +slotWebSearch browsermainwindow.cpp /^void BrowserMainWindow::slotWebSearch()$/;" f ln:794 class:BrowserMainWindow +sourceDataChanged history.cpp /^void HistoryFilterModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)$/;" f ln:817 class:HistoryFilterModel +sourceDateRow history.cpp /^int HistoryTreeModel::sourceDateRow(int row) const$/;" f ln:1168 class:HistoryTreeModel +sourceReset history.cpp /^void HistoryFilterModel::sourceReset()$/;" f ln:829 class:HistoryFilterModel +sourceReset history.cpp /^void HistoryCompletionModel::sourceReset()$/;" f ln:1075 class:HistoryCompletionModel +sourceReset history.cpp /^void HistoryTreeModel::sourceReset()$/;" f ln:1282 class:HistoryTreeModel +sourceRowsInserted history.cpp /^void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start, int end)$/;" f ln:922 class:HistoryFilterModel +sourceRowsInserted history.cpp /^void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, int end)$/;" f ln:1289 class:HistoryTreeModel +sourceRowsRemoved history.cpp /^void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int end)$/;" f ln:945 class:HistoryFilterModel +sourceRowsRemoved history.cpp /^void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, int end)$/;" f ln:1330 class:HistoryTreeModel +sslErrors networkaccessmanager.cpp /^void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList &error)$/;" f ln:133 class:NetworkAccessManager +stop downloadmanager.cpp /^void DownloadItem::stop()$/;" f ln:142 class:DownloadItem +tabWidget browsermainwindow.cpp /^TabWidget *BrowserMainWindow::tabWidget() const$/;" f ln:845 class:BrowserMainWindow +textChanged cookiejar.cpp /^void CookiesExceptionsDialog::textChanged(const QString &text)$/;" f ln:749 class:CookiesExceptionsDialog +timerEvent autosaver.cpp /^void AutoSaver::timerEvent(QTimerEvent *event)$/;" f ln:54 class:AutoSaver +triggered modelmenu.cpp /^void ModelMenu::triggered(QAction *action)$/;" f ln:203 class:ModelMenu +tryAgain downloadmanager.cpp /^void DownloadItem::tryAgain()$/;" f ln:160 class:DownloadItem +updateCurrent tabwidget.cpp /^void WebActionMapper::updateCurrent(QWebPage *currentParent)$/;" f ln:898 class:WebActionMapper +updateHistoryItem history.cpp /^void HistoryManager::updateHistoryItem(const KUrl &url, const QString &title)$/;" f ln:175 class:HistoryManager +updateInfoLabel downloadmanager.cpp /^void DownloadItem::updateInfoLabel()$/;" f ln:229 class:DownloadItem +updateItemCount downloadmanager.cpp /^void DownloadManager::updateItemCount()$/;" f ln:500 class:DownloadManager +updateRow downloadmanager.cpp /^void DownloadManager::updateRow()$/;" f ln:382 class:DownloadManager +updateStatusbarActionText browsermainwindow.cpp /^void BrowserMainWindow::updateStatusbarActionText(bool visible)$/;" f ln:420 class:BrowserMainWindow +url webview.cpp /^KUrl WebView::url() const$/;" f ln:260 class:WebView +webAction tabwidget.cpp /^QWebPage::WebAction WebActionMapper::webAction() const$/;" f ln:867 class:WebActionMapper +webView tabwidget.cpp /^WebView *TabWidget::webView(int index) const$/;" f ln:426 class:TabWidget +webViewIconChanged tabwidget.cpp /^void TabWidget::webViewIconChanged()$/;" f ln:642 class:TabWidget +webViewIconChanged urlbar.cpp /^void UrlBar::webViewIconChanged()$/;" f ln:88 class:UrlBar +webViewIndex tabwidget.cpp /^int TabWidget::webViewIndex(WebView *webView) const$/;" f ln:450 class:TabWidget +webViewLoadStarted tabwidget.cpp /^void TabWidget::webViewLoadStarted()$/;" f ln:631 class:TabWidget +webViewTitleChanged tabwidget.cpp /^void TabWidget::webViewTitleChanged(const QString &title)$/;" f ln:654 class:TabWidget +webViewUrlChanged tabwidget.cpp /^void TabWidget::webViewUrlChanged(const QUrl &url)$/;" f ln:667 class:TabWidget +webViewUrlChanged urlbar.cpp /^void UrlBar::webViewUrlChanged(const QUrl &url)$/;" f ln:81 class:UrlBar +wheelEvent webview.cpp /^void WebView::wheelEvent(QWheelEvent *event)$/;" f ln:209 class:WebView +windowCloseRequested tabwidget.cpp /^void TabWidget::windowCloseRequested()$/;" f ln:549 class:TabWidget -- cgit v1.2.1 From 86b08454a5ae33e24e545ba74ff8fcd1c3c56849 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 10:56:07 +0100 Subject: Some adjs on Actions management --- src/browsermainwindow.cpp | 3 +++ src/tabwidget.cpp | 26 ++++++++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index f17f450a..f6691101 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -352,6 +352,9 @@ void BrowserMainWindow::setupMenu() KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); toolsMenu->addAction( i18n("Downloads"), this, SLOT( slotDownloadManager() ), i18n("Alt+Ctrl+D") ); + + toolsMenu->addSeparator(); + toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); action->setCheckable(true); diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index fc545bd3..7f39bd8a 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -67,25 +67,25 @@ void TabBar::selectTabAction() void TabBar::contextMenuRequested(const QPoint &position) { - QMenu menu; - menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); + KMenu menu; + menu.addAction(i18n("New &Tab"), this, SIGNAL( newTab() ), QKeySequence::AddTab); int index = tabAt(position); if (-1 != index) { - QAction *action = menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); + KAction *action = (KAction * ) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); action->setData(index); menu.addSeparator(); - action = menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); + action = (KAction * ) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); action->setData(index); - action = menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); + action = (KAction * ) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); action->setData(index); menu.addSeparator(); - action = menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); + action = (KAction * ) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); action->setData(index); } else @@ -99,7 +99,7 @@ void TabBar::contextMenuRequested(const QPoint &position) void TabBar::cloneTab() { - if (QAction *action = qobject_cast(sender())) + if (KAction *action = qobject_cast(sender())) { int index = action->data().toInt(); emit cloneTab(index); @@ -109,7 +109,7 @@ void TabBar::cloneTab() void TabBar::closeTab() { - if (QAction *action = qobject_cast(sender())) + if (KAction *action = qobject_cast(sender())) { int index = action->data().toInt(); emit closeTab(index); @@ -119,7 +119,7 @@ void TabBar::closeTab() void TabBar::closeOtherTabs() { - if (QAction *action = qobject_cast(sender())) + if (KAction *action = qobject_cast(sender())) { int index = action->data().toInt(); emit closeOtherTabs(index); @@ -183,7 +183,7 @@ void TabBar::dropEvent(QDropEvent *event) void TabBar::reloadTab() { - if (QAction *action = qobject_cast(sender())) { + if (KAction *action = qobject_cast(sender())) { int index = action->data().toInt(); emit reloadTab(index); } @@ -231,8 +231,7 @@ TabWidget::TabWidget(QWidget *parent) QList shortcuts; shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketRight)); - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Less)); + shortcuts.append(QKeySequence(Qt::CTRL + Qt::Key_Tab)); m_nextTabAction->setShortcuts(shortcuts); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); @@ -240,8 +239,7 @@ TabWidget::TabWidget(QWidget *parent) shortcuts.clear(); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BracketLeft)); - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_Greater)); + shortcuts.append( QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab) );; m_previousTabAction->setShortcuts(shortcuts); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); -- cgit v1.2.1 From 62ba147d56dfc18eeb9656874723e31ca1d7a5c8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 11:58:44 +0100 Subject: Removed unuseful actions.. --- src/browsermainwindow.cpp | 87 ++++++----------------------------------------- src/browsermainwindow.h | 6 ++-- src/tabwidget.cpp | 22 +++++------- 3 files changed, 22 insertions(+), 93 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index f6691101..04447f87 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -278,10 +278,10 @@ void BrowserMainWindow::setupMenu() // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); - m_viewStatusbar = new KAction(this); - updateStatusbarActionText(true); + m_viewStatusbar = KStandardAction::showStatusbar( this, SLOT(slotViewStatusbar() ), this); +/* updateStatusbarActionText(true); m_viewStatusbar->setShortcut( i18n("Ctrl+/") ); - connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar())); + connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar()));*/ viewMenu->addAction(m_viewStatusbar); viewMenu->addSeparator(); @@ -355,7 +355,6 @@ void BrowserMainWindow::setupMenu() toolsMenu->addSeparator(); - toolsMenu->addAction( i18n("Web &Search"), this, SLOT(slotWebSearch()), QKeySequence( tr("Ctrl+K", "Web Search"))); action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); action->setCheckable(true); @@ -370,9 +369,6 @@ void BrowserMainWindow::setupMenu() } - - - void BrowserMainWindow::setupToolBar() { m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, true, false, false); @@ -409,31 +405,21 @@ void BrowserMainWindow::setupToolBar() } - -void BrowserMainWindow::slotAddBookmark() -{ -// WebView *webView = currentTab(); -// QString url = webView->url().toString(); -// QString title = webView->title(); -// AddBookmarkDialog dialog(url, title); -// dialog.exec(); -} - - void BrowserMainWindow::updateStatusbarActionText(bool visible) { m_viewStatusbar->setText(!visible ? i18n("Show Status Bar") : i18n("Hide Status Bar")); } - - void BrowserMainWindow::slotViewStatusbar() { - if (statusBar()->isVisible()) { + if (statusBar()->isVisible()) + { updateStatusbarActionText(false); statusBar()->close(); - } else { + } + else + { updateStatusbarActionText(true); statusBar()->show(); } @@ -441,8 +427,6 @@ void BrowserMainWindow::slotViewStatusbar() } - - KUrl BrowserMainWindow::guessUrlFromString(const QString &string) { QString urlStr = string.trimmed(); @@ -498,23 +482,18 @@ KUrl BrowserMainWindow::guessUrlFromString(const QString &string) } - - void BrowserMainWindow::loadUrl(const KUrl &url) { loadPage( url.url() ); } - - void BrowserMainWindow::slotDownloadManager() { BrowserApplication::downloadManager()->show(); } - void BrowserMainWindow::slotSelectLineEdit() { m_tabWidget->currentLineEdit()->selectAll(); @@ -522,15 +501,12 @@ void BrowserMainWindow::slotSelectLineEdit() } - void BrowserMainWindow::slotFileSaveAs() { BrowserApplication::downloadManager()->download(currentTab()->url(), true); } - - void BrowserMainWindow::slotPreferences() { SettingsDialog *s = new SettingsDialog(this); @@ -538,16 +514,12 @@ void BrowserMainWindow::slotPreferences() } - - void BrowserMainWindow::slotUpdateStatusbar(const QString &string) { statusBar()->showMessage(string, 2000); } - - void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) { if (title.isEmpty()) { @@ -558,7 +530,6 @@ void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) } - void BrowserMainWindow::slotFileNew() { BrowserApplication::instance()->newMainWindow(); @@ -567,8 +538,6 @@ void BrowserMainWindow::slotFileNew() } - - void BrowserMainWindow::slotFileOpen() { QString file = QFileDialog::getOpenFileName(this, i18n("Open Web Resource"), QString(), @@ -581,8 +550,6 @@ void BrowserMainWindow::slotFileOpen() } - - void BrowserMainWindow::slotFilePrintPreview() { if (!currentTab()) @@ -593,7 +560,6 @@ void BrowserMainWindow::slotFilePrintPreview() } - void BrowserMainWindow::slotFilePrint() { if (!currentTab()) @@ -602,7 +568,6 @@ void BrowserMainWindow::slotFilePrint() } - void BrowserMainWindow::printRequested(QWebFrame *frame) { QPrinter printer; @@ -614,7 +579,6 @@ void BrowserMainWindow::printRequested(QWebFrame *frame) } - void BrowserMainWindow::slotPrivateBrowsing() { QWebSettings *settings = QWebSettings::globalSettings(); @@ -654,7 +618,6 @@ void BrowserMainWindow::slotPrivateBrowsing() } - void BrowserMainWindow::closeEvent(QCloseEvent *event) { if (m_tabWidget->count() > 1) @@ -710,7 +673,6 @@ void BrowserMainWindow::slotFindPrevious() } - void BrowserMainWindow::slotViewTextBigger() { if (!currentTab()) @@ -719,7 +681,6 @@ void BrowserMainWindow::slotViewTextBigger() } - void BrowserMainWindow::slotViewTextNormal() { if (!currentTab()) @@ -728,7 +689,6 @@ void BrowserMainWindow::slotViewTextNormal() } - void BrowserMainWindow::slotViewTextSmaller() { if (!currentTab()) @@ -737,8 +697,6 @@ void BrowserMainWindow::slotViewTextSmaller() } - - void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) { if (makeFullScreen) @@ -766,8 +724,6 @@ void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) } - - void BrowserMainWindow::slotViewPageSource() { if (!currentTab()) @@ -782,7 +738,6 @@ void BrowserMainWindow::slotViewPageSource() } - void BrowserMainWindow::slotHome() { KConfig config("rekonqrc"); @@ -792,17 +747,6 @@ void BrowserMainWindow::slotHome() } - - -void BrowserMainWindow::slotWebSearch() -{ -// m_toolbarSearch->lineEdit()->selectAll(); -// m_toolbarSearch->lineEdit()->setFocus(); -} - - - - void BrowserMainWindow::slotToggleInspector(bool enable) { QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); @@ -820,8 +764,6 @@ void BrowserMainWindow::slotToggleInspector(bool enable) } - - void BrowserMainWindow::slotSwapFocus() { if (currentTab()->hasFocus()) @@ -831,20 +773,17 @@ void BrowserMainWindow::slotSwapFocus() } - void BrowserMainWindow::loadPage(const QString &page) { if (!currentTab() || page.isEmpty()) return; - QUrl url = guessUrlFromString(page); - m_tabWidget->currentLineEdit()->setText(url.toString()); + KUrl url = guessUrlFromString(page); + m_tabWidget->currentLineEdit()->setText( url.prettyUrl() ); m_tabWidget->loadUrlInCurrentTab(url); } - - TabWidget *BrowserMainWindow::tabWidget() const { return m_tabWidget; @@ -879,8 +818,6 @@ void BrowserMainWindow::slotLoadProgress(int progress) } - - void BrowserMainWindow::slotAboutToShowBackMenu() { m_historyBackMenu->clear(); @@ -901,7 +838,6 @@ void BrowserMainWindow::slotAboutToShowBackMenu() } - void BrowserMainWindow::slotShowWindow() { if (KAction *action = qobject_cast(sender())) @@ -918,8 +854,6 @@ void BrowserMainWindow::slotShowWindow() } - - void BrowserMainWindow::slotOpenActionUrl(QAction *action) { int offset = action->data().toInt(); @@ -953,6 +887,7 @@ void BrowserMainWindow::slotOpenNext() history->goToItem( history->forwardItem() ); } + void BrowserMainWindow::geometryChangeRequested(const QRect &geometry) { setGeometry(geometry); diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 811584f8..19ab51c9 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -88,7 +89,6 @@ private slots: void slotPrivateBrowsing(); void slotFileSaveAs(); - void slotAddBookmark(); void slotViewTextBigger(); void slotViewTextNormal(); void slotViewTextSmaller(); @@ -97,7 +97,6 @@ private slots: void slotViewFullScreen(bool enable); void slotViewFindBar(); - void slotWebSearch(); void slotToggleInspector(bool enable); void slotDownloadManager(); void slotSelectLineEdit(); @@ -137,9 +136,8 @@ private: KAction *m_reload; KAction *m_stopReload; KAction *m_goHome; - KAction *m_viewStatusbar; + KToggleAction *m_viewStatusbar; KAction *m_restoreLastSession; - KAction *m_addBookmark; KIcon m_reloadIcon; KIcon m_stopIcon; diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 7f39bd8a..51a404d0 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -28,6 +28,9 @@ #include "urlbar.h" #include "webview.h" +// KDE Includes +#include + // Qt Includes #include #include @@ -183,7 +186,8 @@ void TabBar::dropEvent(QDropEvent *event) void TabBar::reloadTab() { - if (KAction *action = qobject_cast(sender())) { + if (KAction *action = qobject_cast(sender())) + { int index = action->data().toInt(); emit reloadTab(index); } @@ -218,29 +222,21 @@ TabWidget::TabWidget(QWidget *parent) // Actions m_newTabAction = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); - m_newTabAction->setShortcuts(KShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_N, Qt::CTRL+Qt::Key_T)); + m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); m_newTabAction->setIconVisibleInMenu(false); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - m_closeTabAction->setShortcut(Qt::CTRL+Qt::Key_W); + m_closeTabAction->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); m_closeTabAction->setIconVisibleInMenu(false); connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_nextTabAction = new KAction(i18n("Show Next Tab"), this); - QList shortcuts; - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceRight)); - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageDown)); - shortcuts.append(QKeySequence(Qt::CTRL + Qt::Key_Tab)); - m_nextTabAction->setShortcuts(shortcuts); + m_nextTabAction->setShortcut( KShortcut( Qt::CTRL | Qt::Key_Tab ) ); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); - shortcuts.clear(); - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_BraceLeft)); - shortcuts.append(QKeySequence(Qt::CTRL | Qt::Key_PageUp)); - shortcuts.append( QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab) );; - m_previousTabAction->setShortcuts(shortcuts); + m_previousTabAction->setShortcut( KShortcut( Qt::CTRL | Qt::SHIFT | Qt::Key_Tab ) ); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); m_recentlyClosedTabsMenu = new KMenu(this); -- cgit v1.2.1 From d34e929a3f85d13cfd99a4ead5af9e5986a18626 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 12:12:49 +0100 Subject: better fullscreen-ing.. --- src/browsermainwindow.cpp | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 04447f87..3be8adf3 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -39,9 +39,8 @@ #include #include #include +#include #include -#include -#include // Qt Includes #include @@ -279,9 +278,6 @@ void BrowserMainWindow::setupMenu() KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); m_viewStatusbar = KStandardAction::showStatusbar( this, SLOT(slotViewStatusbar() ), this); -/* updateStatusbarActionText(true); - m_viewStatusbar->setShortcut( i18n("Ctrl+/") ); - connect(m_viewStatusbar, SIGNAL(triggered()), this, SLOT(slotViewStatusbar()));*/ viewMenu->addAction(m_viewStatusbar); viewMenu->addSeparator(); @@ -308,8 +304,9 @@ void BrowserMainWindow::setupMenu() // TODO set encoding viewMenu->addAction( i18n("Page S&ource"), this, SLOT( slotViewPageSource() ), i18n("Ctrl+Alt+U")); - action = (KAction *) viewMenu->addAction( i18n("&Full Screen"), this, SLOT(slotViewFullScreen(bool)), Qt::Key_F11); - action->setCheckable(true); + + KToggleFullScreenAction *tfsa = KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, this); + viewMenu->addAction( tfsa ); // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- HistoryMenu *historyMenu = new HistoryMenu(this); @@ -320,13 +317,13 @@ void BrowserMainWindow::setupMenu() QList historyActions; m_historyBack = new KAction( i18n("Back"), this); + m_historyBack->setShortcut( KShortcut( QKeySequence::Back ) ); m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); -// m_historyBack->setShortcuts(QKeySequence::Back); FIXME m_historyBack->setIconVisibleInMenu(false); m_historyForward = new KAction( i18n("Forward"), this); + m_historyForward->setShortcut( KShortcut( QKeySequence::Forward ) ); m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); -// m_historyForward->setShortcuts(QKeySequence::Forward); FIXME m_historyForward->setIconVisibleInMenu(false); m_restoreLastSession = new KAction( i18n("Restore Last Session"), this); @@ -697,30 +694,10 @@ void BrowserMainWindow::slotViewTextSmaller() } +// TODO improve this void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) { - if (makeFullScreen) - { - showFullScreen(); - } - else - { - if ( isMinimized() ) - { - showMinimized(); - } - else - { - if (isMaximized()) - { - showMaximized(); - } - else - { - showNormal(); - } - } - } + KToggleFullScreenAction::setFullScreen( this, makeFullScreen ); } -- cgit v1.2.1 From ded81093686f9d180f9bd0b3587ef40b82918ad2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 12:24:45 +0100 Subject: ctrl + tab switching: try 5.. --- src/tabwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 51a404d0..57e80856 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -30,6 +30,7 @@ // KDE Includes #include +#include // Qt Includes #include @@ -232,11 +233,11 @@ TabWidget::TabWidget(QWidget *parent) connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); m_nextTabAction = new KAction(i18n("Show Next Tab"), this); - m_nextTabAction->setShortcut( KShortcut( Qt::CTRL | Qt::Key_Tab ) ); + m_nextTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); - m_previousTabAction->setShortcut( KShortcut( Qt::CTRL | Qt::SHIFT | Qt::Key_Tab ) ); + m_previousTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); m_recentlyClosedTabsMenu = new KMenu(this); -- cgit v1.2.1 From a02a9101fe127211de1fd24f6876b87686309997 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 23:30:36 +0100 Subject: QTabWidget --> KTabWidget --- src/autosaver.cpp | 9 ++++++--- src/autosaver.h | 8 +++----- src/tabwidget.cpp | 28 ++++++++++++++++++++-------- src/tabwidget.h | 10 +++++----- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/src/autosaver.cpp b/src/autosaver.cpp index 4b83b65d..c1164e60 100644 --- a/src/autosaver.cpp +++ b/src/autosaver.cpp @@ -20,25 +20,26 @@ #include "autosaver.h" -#include -#include -#include +#include #include #define AUTOSAVE_IN 1000 * 3 // seconds #define MAXWAIT 1000 * 15 // seconds + AutoSaver::AutoSaver(QObject *parent) : QObject(parent) { Q_ASSERT(parent); } + AutoSaver::~AutoSaver() { if (m_timer.isActive()) qWarning() << "AutoSaver: still active when destroyed, changes not saved."; } + void AutoSaver::changeOccurred() { if (m_firstChange.isNull()) @@ -51,6 +52,7 @@ void AutoSaver::changeOccurred() } } + void AutoSaver::timerEvent(QTimerEvent *event) { if (event->timerId() == m_timer.timerId()) { @@ -60,6 +62,7 @@ void AutoSaver::timerEvent(QTimerEvent *event) } } + void AutoSaver::saveIfNeccessary() { if (!m_timer.isActive()) diff --git a/src/autosaver.h b/src/autosaver.h index d8004a9d..70dca53a 100644 --- a/src/autosaver.h +++ b/src/autosaver.h @@ -21,17 +21,15 @@ #ifndef AUTOSAVER_H #define AUTOSAVER_H -#include -#include -#include +#include /* This class will call the save() slot on the parent object when the parent changes. It will wait several seconds after changed() to combining multiple changes and prevent continuous writing to disk. */ -class AutoSaver : public QObject { - +class AutoSaver : public QObject +{ Q_OBJECT public: diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 57e80856..b8e9c748 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -57,6 +57,11 @@ TabBar::TabBar(QWidget *parent) } +TabBar::~TabBar() +{ +} + + void TabBar::selectTabAction() { if (QShortcut *shortCut = qobject_cast(sender())) @@ -199,7 +204,7 @@ void TabBar::reloadTab() TabWidget::TabWidget(QWidget *parent) - : QTabWidget(parent) + : KTabWidget(parent) , m_recentlyClosedTabsAction(0) , m_newTabAction(0) , m_closeTabAction(0) @@ -266,6 +271,11 @@ TabWidget::TabWidget(QWidget *parent) } +TabWidget::~TabWidget() +{ +} + + void TabWidget::clear() { // clear the recently closed tabs @@ -310,7 +320,6 @@ void TabWidget::reloadTab(int index) } - void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction) { if (!action) @@ -588,8 +597,10 @@ void TabWidget::closeTab(int index) return; bool hasFocus = false; - if (WebView *tab = webView(index)) { - if (tab->isModified()) { + if (WebView *tab = webView(index)) + { + if (tab->isModified()) + { QMessageBox closeConfirmation(tab); closeConfirmation.setWindowFlags(Qt::Sheet); closeConfirmation.setWindowTitle(i18n("Do you really want to close this page?")); @@ -627,9 +638,10 @@ void TabWidget::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { - QIcon icon(QLatin1String(":loading.gif")); // FIXME - setTabIcon(index, icon); + if (-1 != index) + { +// QIcon icon(QLatin1String(":loading.gif")); + setTabIcon(index, KIcon("rekonq") ); } } @@ -694,7 +706,7 @@ void TabWidget::aboutToShowRecentTriggeredAction(QAction *action) void TabWidget::mouseDoubleClickEvent(QMouseEvent *event) { - if ( !childAt(event->pos()) + if ( !childAt(event->pos() ) // Remove the line below when QTabWidget does not have a one pixel frame && event->pos().y() < (tabBar()->y() + tabBar()->height())) { diff --git a/src/tabwidget.h b/src/tabwidget.h index 6e9f2f66..020376e1 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -45,6 +45,7 @@ signals: public: TabBar(QWidget *parent = 0); + ~TabBar(); protected: void mousePressEvent(QMouseEvent* event); @@ -72,7 +73,6 @@ private: // ---------------------------------------------------------------------------------------------------------------------------- - #include class WebView; @@ -112,9 +112,7 @@ private: #include #include #include - -// Qt Includes -#include +#include QT_BEGIN_NAMESPACE class QCompleter; @@ -127,7 +125,7 @@ QT_END_NAMESPACE Connects up the current tab's signals to this class's signal and uses WebActionMapper to proxy the actions. */ -class TabWidget : public QTabWidget +class TabWidget : public KTabWidget { Q_OBJECT @@ -150,6 +148,8 @@ signals: public: TabWidget(QWidget *parent = 0); + ~TabWidget(); + void clear(); void addWebAction(KAction *action, QWebPage::WebAction webAction); -- cgit v1.2.1 From 6f1c8c3bddd3621ed4925853097237913ff9ff99 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 23:36:06 +0100 Subject: Fixed Window Icon --- src/browserapplication.cpp | 3 ++- src/findbar.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 55c60ae9..897037ab 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -95,6 +95,8 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server KConfigGroup group = config.group("sessions"); m_lastSession = group.readEntry( QString("lastSession"), QByteArray() ); + setWindowIcon( KIcon("rekonq") ); + QTimer::singleShot(0, this, SLOT( postLaunch() ) ); } @@ -125,7 +127,6 @@ void BrowserApplication::postLaunch() } QWebSettings::setIconDatabasePath(directory); - setWindowIcon( KIcon("rekonq") ); loadSettings(); // newMainWindow() needs to be called in main() for this to happen diff --git a/src/findbar.cpp b/src/findbar.cpp index feafb98e..14d52001 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include -- cgit v1.2.1 From 3349db61eed34e3c1fb274d66ac55405fa188fdc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 6 Dec 2008 23:42:30 +0100 Subject: Fixed crash when closing rekonq with more than one tab --- TODO | 1 + src/browserapplication.cpp | 4 ++-- src/browsermainwindow.cpp | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index c2ac09d0..2991ac44 100644 --- a/TODO +++ b/TODO @@ -5,6 +5,7 @@ Road to 0.0.1 (first release) + some porting NEXT.. +- Fixing QByteArray save/load state!! - system SELECT ALL - better FULL SCREEN - simplify history diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 897037ab..8a1ffc5a 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -203,7 +203,7 @@ void BrowserApplication::clean() void BrowserApplication::saveSession() { QWebSettings *globalSettings = QWebSettings::globalSettings(); - if (globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) + if ( globalSettings->testAttribute( QWebSettings::PrivateBrowsingEnabled ) ) return; clean(); @@ -250,7 +250,7 @@ void BrowserApplication::restoreLastSession() BrowserMainWindow *newWindow = 0; if (m_mainWindows.count() == 1 && mainWindow()->tabWidget()->count() == 1 - && mainWindow()->currentTab()->url() == QUrl()) + && mainWindow()->currentTab()->url() == KUrl()) { newWindow = mainWindow(); } diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 3be8adf3..4f242225 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -162,7 +162,8 @@ QByteArray BrowserMainWindow::saveState(bool withTabs) const stream << size(); // stream << !( statusBar()->isHidden() ); FIXME if (withTabs) - stream << tabWidget()->saveState(); +// stream << tabWidget()->saveState(); + ; else stream << QByteArray(); return data; -- cgit v1.2.1 From c8279e0c4a76db65547e6c711b8e7717e0d28059 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 7 Dec 2008 00:18:36 +0100 Subject: No more QmessageBox here.. --- src/browsermainwindow.cpp | 24 ++++++++++-------------- src/networkaccessmanager.cpp | 11 +++++------ src/tabwidget.cpp | 18 ++++++++---------- src/webview.cpp | 5 ++--- 4 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 4f242225..6ca9c256 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -41,6 +41,7 @@ #include #include #include +#include // Qt Includes #include @@ -49,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -593,10 +593,8 @@ void BrowserMainWindow::slotPrivateBrowsing() " Until you close the window, you can still click the Back and Forward buttons" \ " to return to the webpages you have opened."); - QMessageBox::StandardButton button = QMessageBox::question(this, QString(), text, - QMessageBox::Ok | QMessageBox::Cancel, - QMessageBox::Ok); - if (button == QMessageBox::Ok) + int button = KMessageBox::questionYesNo( this, text, title ); + if (button == KMessageBox::Ok) { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); } @@ -620,12 +618,10 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event) { if (m_tabWidget->count() > 1) { - int ret = QMessageBox::warning(this, QString(), - i18n("Are you sure you want to close the window?" - " There are %1 tab open" , m_tabWidget->count() ) , - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (ret == QMessageBox::No) + int ret = KMessageBox::warningYesNo(this, + i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , + QString() ); + if (ret == KMessageBox::No) { event->ignore(); return; @@ -730,11 +726,11 @@ void BrowserMainWindow::slotToggleInspector(bool enable) QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); if (enable) { - int result = QMessageBox::question(this, i18n("Web Inspector"), + int result = KMessageBox::questionYesNo(this, i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" "Do you want to reload all pages?"), - QMessageBox::Yes | QMessageBox::No); - if (result == QMessageBox::Yes) + i18n("Web Inspector") ); + if (result == KMessageBox::Yes) { m_tabWidget->reloadAllTabs(); } diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 79549d25..c5967d2a 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -23,15 +23,16 @@ #include "networkaccessmanager.h" #include "browserapplication.h" #include "browsermainwindow.h" + #include "ui_passworddialog.h" #include "ui_proxy.h" // KDE Includes #include +#include // Qt Includes #include -#include #include #include #include @@ -138,11 +139,9 @@ void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QListurl().toString() + "\n\n" + QString(errors) + "\n\n", - QMessageBox::Yes | QMessageBox::No, - QMessageBox::No); - if (ret == QMessageBox::Yes) + int ret = KMessageBox::warningYesNo( mainWindow, + i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n"); + if (ret == KMessageBox::Yes) reply->ignoreSslErrors(); } #endif diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index b8e9c748..01f9bd6c 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -31,6 +31,7 @@ // KDE Includes #include #include +#include // Qt Includes #include @@ -334,6 +335,7 @@ void TabWidget::currentChanged(int index) if (!webView) return; +// FIXME Q_ASSERT( m_lineEdits->count() == count() ); WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); @@ -601,16 +603,12 @@ void TabWidget::closeTab(int index) { if (tab->isModified()) { - QMessageBox closeConfirmation(tab); - closeConfirmation.setWindowFlags(Qt::Sheet); - closeConfirmation.setWindowTitle(i18n("Do you really want to close this page?")); - closeConfirmation.setInformativeText(i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n")); - closeConfirmation.setIcon(QMessageBox::Question); - closeConfirmation.addButton(QMessageBox::Yes); - closeConfirmation.addButton(QMessageBox::No); - closeConfirmation.setEscapeButton(QMessageBox::No); - if (closeConfirmation.exec() == QMessageBox::No) + int risp = KMessageBox::questionYesNo( this , + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no() ); + if( risp == KMessageBox::No ) return; } hasFocus = tab->hasFocus(); diff --git a/src/webview.cpp b/src/webview.cpp index 2e97c486..b14b4936 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -32,10 +32,8 @@ #include #include -#include #include #include -//#include #include @@ -53,7 +51,8 @@ WebPage::WebPage(QObject *parent) BrowserMainWindow *WebPage::mainWindow() { QObject *w = this->parent(); - while (w) { + while (w) + { if (BrowserMainWindow *mw = qobject_cast(w)) return mw; w = w->parent(); -- cgit v1.2.1 From 5516a5d3cb9154a6f1d64ee9b776c1f93db618ba Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 8 Dec 2008 01:00:38 +0100 Subject: Add destrctors'code, as needed. Fixed closing application bug. --- src/browsermainwindow.cpp | 3 ++- src/tabwidget.cpp | 5 +++-- src/urlbar.cpp | 3 --- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 6ca9c256..d6327300 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -111,6 +111,7 @@ BrowserMainWindow::~BrowserMainWindow() { m_autoSaver->changeOccurred(); m_autoSaver->saveIfNeccessary(); + delete m_navigationBar; } @@ -390,7 +391,7 @@ void BrowserMainWindow::setupToolBar() m_navigationBar->addAction(m_goHome); connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); - m_navigationBar->addWidget(m_tabWidget->lineEditStack()); + m_navigationBar->addWidget( m_tabWidget->lineEditStack() ); m_searchBar = new SearchBar(m_navigationBar); m_navigationBar->addWidget(m_searchBar); diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 01f9bd6c..72574596 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -274,7 +274,9 @@ TabWidget::TabWidget(QWidget *parent) TabWidget::~TabWidget() { -} + delete m_lineEditCompleter; + delete m_recentlyClosedTabsMenu; +} void TabWidget::clear() @@ -335,7 +337,6 @@ void TabWidget::currentChanged(int index) if (!webView) return; -// FIXME Q_ASSERT( m_lineEdits->count() == count() ); WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 1ee02dc3..098ba027 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -54,9 +54,6 @@ UrlBar::UrlBar(QWidget *parent) UrlBar::~UrlBar() { - delete m_webView; - delete m_iconLabel; - delete m_lineEdit; } -- cgit v1.2.1 From 22f4427d614344550ca6949695aa3456d3789165 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 9 Dec 2008 01:28:57 +0100 Subject: made the urlbar a KHistoryComboBox. Really beautiful widget!! --- src/tabwidget.cpp | 10 +++++----- src/tabwidget.h | 8 +++++--- src/urlbar.cpp | 33 ++++++++++----------------------- src/urlbar.h | 15 ++++++--------- 4 files changed, 26 insertions(+), 40 deletions(-) diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 72574596..58ea75c0 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -286,7 +286,7 @@ void TabWidget::clear() // clear the line edit history for (int i = 0; i < m_lineEdits->count(); ++i) { - KLineEdit *qLineEdit = lineEdit(i); + QLineEdit *qLineEdit = lineEdit(i); qLineEdit->setText(qLineEdit->text()); } } @@ -409,7 +409,7 @@ QWidget *TabWidget::lineEditStack() const } -KLineEdit *TabWidget::currentLineEdit() const +QLineEdit *TabWidget::currentLineEdit() const { return lineEdit(m_lineEdits->currentIndex()); } @@ -421,7 +421,7 @@ WebView *TabWidget::currentWebView() const } -KLineEdit *TabWidget::lineEdit(int index) const +QLineEdit *TabWidget::lineEdit(int index) const { UrlBar *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); if (urlLineEdit) @@ -465,7 +465,7 @@ WebView *TabWidget::newTab(bool makeCurrent) { // line edit UrlBar *urlLineEdit = new UrlBar; - KLineEdit *lineEdit = urlLineEdit->lineEdit(); + QLineEdit *lineEdit = urlLineEdit->lineEdit(); if (!m_lineEditCompleter && count() > 0) { HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); @@ -544,7 +544,7 @@ void TabWidget::reloadAllTabs() void TabWidget::lineEditReturnPressed() { - if (KLineEdit *lineEdit = qobject_cast(sender())) + if (QLineEdit *lineEdit = qobject_cast(sender())) { emit loadPage(lineEdit->text()); if (m_lineEdits->currentWidget() == lineEdit) diff --git a/src/tabwidget.h b/src/tabwidget.h index 020376e1..27cc4611 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -110,10 +110,12 @@ private: // KDE Includes #include -#include #include #include +// Qt Includes +#include + QT_BEGIN_NAMESPACE class QCompleter; class QMenu; @@ -160,10 +162,10 @@ public: KAction *previousTabAction() const; QWidget *lineEditStack() const; - KLineEdit *currentLineEdit() const; + QLineEdit *currentLineEdit() const; WebView *currentWebView() const; WebView *webView(int index) const; - KLineEdit *lineEdit(int index) const; + QLineEdit *lineEdit(int index) const; int webViewIndex(WebView *webView) const; QByteArray saveState() const; diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 098ba027..e45c0bb0 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -23,30 +23,14 @@ #include "browserapplication.h" -// Qt Includes -#include - -UrlBar::UrlBar(QWidget *parent) - : QWidget(parent) +UrlBar::UrlBar(KHistoryComboBox *parent) + : KHistoryComboBox(parent) , m_webView(0) - , m_iconLabel(0) , m_lineEdit(0) { - // icon - m_iconLabel = new QLabel; - m_iconLabel->resize(16, 16); - - m_lineEdit = new KLineEdit; - - QHBoxLayout *layout = new QHBoxLayout; - layout->addWidget(m_iconLabel); - layout->addWidget(m_lineEdit); - setLayout(layout); - - m_defaultBaseColor = palette().color(QPalette::Base); -// setPalette( QPalette(Qt::white) ); - setAutoFillBackground( false ); + m_lineEdit = new QLineEdit; + setLineEdit( m_lineEdit ); webViewIconChanged(); } @@ -57,7 +41,7 @@ UrlBar::~UrlBar() } -KLineEdit *UrlBar::lineEdit() +QLineEdit *UrlBar::lineEdit() { return m_lineEdit; } @@ -67,7 +51,6 @@ void UrlBar::setWebView(WebView *webView) { Q_ASSERT(!m_webView); m_webView = webView; -// m_iconLabel->m_webView = webView; connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); @@ -87,7 +70,11 @@ void UrlBar::webViewIconChanged() KUrl url = (m_webView) ? m_webView->url() : KUrl(); QIcon icon = BrowserApplication::instance()->icon(url); QPixmap pixmap(icon.pixmap(16, 16)); - m_iconLabel->setPixmap(pixmap); + QIcon urlIcon = QIcon(pixmap); + + // FIXME simple hack to show Icon in the urlbar, as calling changeUrl() doesn't affect it + removeItem( 0 ); + insertUrl( 0 , urlIcon , url ); } diff --git a/src/urlbar.h b/src/urlbar.h index 5d766a92..fcebc6f9 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -24,23 +24,21 @@ #include "webview.h" // KDE Includes -#include -#include +#include // Qt Includes -#include -#include +#include -class UrlBar : public QWidget +class UrlBar : public KHistoryComboBox { Q_OBJECT public: - UrlBar(QWidget *parent = 0); + UrlBar(KHistoryComboBox *parent = 0); ~UrlBar(); - KLineEdit *lineEdit(); + QLineEdit *lineEdit(); void setWebView(WebView *webView); private slots: @@ -52,8 +50,7 @@ private: WebView *m_webView; - QLabel *m_iconLabel; - KLineEdit *m_lineEdit; + QLineEdit *m_lineEdit; QColor m_defaultBaseColor; }; -- cgit v1.2.1 From c0e5507895a938b19881e1747b26b9914868d61f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 9 Dec 2008 02:29:11 +0100 Subject: Added gray "Search.." on searchbar --- src/searchbar.cpp | 8 +++++++- src/settings.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/searchbar.cpp b/src/searchbar.cpp index a2f1217f..61bb61a5 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -23,6 +23,7 @@ // Qt Includes #include +#include SearchBar::SearchBar(QWidget *parent) : QWidget(parent), @@ -31,6 +32,11 @@ SearchBar::SearchBar(QWidget *parent) : m_lineEdit = new KLineEdit(this); m_lineEdit->setClearButtonShown( true ); + QPalette palette; + palette.setColor( QPalette::Text, Qt::gray ); + m_lineEdit->setPalette( palette ); + m_lineEdit->setText( "Search.." ); + QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(m_lineEdit); setLayout(layout); @@ -50,7 +56,7 @@ void SearchBar::searchNow() url.addQueryItem(QLatin1String("q"), searchText); url.addQueryItem(QLatin1String("ie"), QLatin1String("UTF-8")); url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); - url.addQueryItem(QLatin1String("client"), QLatin1String("reKonq")); + url.addQueryItem(QLatin1String("client"), QLatin1String("rekonq")); emit search(url); } diff --git a/src/settings.cpp b/src/settings.cpp index 2a440c19..74376ea8 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -48,7 +48,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) setMainWidget(widget); - setWindowTitle( i18n("Setting reKonq..") ); + setWindowTitle( i18n("Setting rekonq..") ); setButtons( KDialog::Ok | KDialog::Close | KDialog::Apply ); setModal(true); -- cgit v1.2.1 From 2565f1a0b3fa0e345159ae0c85a701467269e1ea Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Dec 2008 00:19:56 +0100 Subject: nothing important --- src/searchbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 61bb61a5..a48803b3 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -44,10 +44,12 @@ SearchBar::SearchBar(QWidget *parent) : connect( lineEdit() , SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); } + SearchBar::~SearchBar() { } + void SearchBar::searchNow() { QString searchText = m_lineEdit->text(); @@ -58,9 +60,9 @@ void SearchBar::searchNow() url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); url.addQueryItem(QLatin1String("client"), QLatin1String("rekonq")); emit search(url); - } + KLineEdit *SearchBar::lineEdit() { return m_lineEdit; -- cgit v1.2.1 From d1edeb480f8539d2a132c5ab9f4e4b2a99d8d2a0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Dec 2008 00:48:03 +0100 Subject: Added Completion to new urlbar. ready for merge.. --- src/searchbar.cpp | 1 - src/urlbar.cpp | 15 +++++++++++++-- src/urlbar.h | 2 ++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/searchbar.cpp b/src/searchbar.cpp index a2f1217f..134b5f33 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -52,7 +52,6 @@ void SearchBar::searchNow() url.addQueryItem(QLatin1String("oe"), QLatin1String("UTF-8")); url.addQueryItem(QLatin1String("client"), QLatin1String("reKonq")); emit search(url); - } KLineEdit *SearchBar::lineEdit() diff --git a/src/urlbar.cpp b/src/urlbar.cpp index e45c0bb0..9be6bca0 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -25,13 +25,17 @@ UrlBar::UrlBar(KHistoryComboBox *parent) - : KHistoryComboBox(parent) + : KHistoryComboBox(true, parent) , m_webView(0) , m_lineEdit(0) { m_lineEdit = new QLineEdit; setLineEdit( m_lineEdit ); - + + // add every item to history + connect( this, SIGNAL( activated( const QString& )), this, SLOT( addToHistory( const QString& ))); + + connect( this, SIGNAL( activated(int) ), this, SLOT( prova() ) ); webViewIconChanged(); } @@ -88,3 +92,10 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const gradient.setColorAt(1, m_defaultBaseColor); return gradient; } + + +void UrlBar::prova() +{ + m_lineEdit->selectAll(); +} + diff --git a/src/urlbar.h b/src/urlbar.h index fcebc6f9..d0f80f17 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -45,6 +45,8 @@ private slots: void webViewUrlChanged(const QUrl &url); void webViewIconChanged(); + void prova(); + private: QLinearGradient generateGradient(const QColor &color) const; -- cgit v1.2.1 From ffdc9de8e498d027f5085f706f0fc6845889efb3 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 10 Dec 2008 00:50:21 +0100 Subject: last adjs.. --- src/urlbar.cpp | 10 +--------- src/urlbar.h | 2 -- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 9be6bca0..4a599463 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -34,8 +34,7 @@ UrlBar::UrlBar(KHistoryComboBox *parent) // add every item to history connect( this, SIGNAL( activated( const QString& )), this, SLOT( addToHistory( const QString& ))); - - connect( this, SIGNAL( activated(int) ), this, SLOT( prova() ) ); + webViewIconChanged(); } @@ -92,10 +91,3 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const gradient.setColorAt(1, m_defaultBaseColor); return gradient; } - - -void UrlBar::prova() -{ - m_lineEdit->selectAll(); -} - diff --git a/src/urlbar.h b/src/urlbar.h index d0f80f17..fcebc6f9 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -45,8 +45,6 @@ private slots: void webViewUrlChanged(const QUrl &url); void webViewIconChanged(); - void prova(); - private: QLinearGradient generateGradient(const QColor &color) const; -- cgit v1.2.1 From 234908390f53163db78829a4835a72014f774103 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 11 Dec 2008 10:28:19 +0100 Subject: QFIleDialog --> KFIleDialog --- src/browsermainwindow.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index d6327300..3375aa89 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -42,16 +42,13 @@ #include #include #include +#include // Qt Includes -#include -#include #include #include #include #include -#include -#include #include #include #include @@ -539,8 +536,10 @@ void BrowserMainWindow::slotFileNew() void BrowserMainWindow::slotFileOpen() { - QString file = QFileDialog::getOpenFileName(this, i18n("Open Web Resource"), QString(), - i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)")); + QString file = KFileDialog::getOpenFileName( KUrl(), + i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), + this, + i18n("Open Web Resource") ); if (file.isEmpty()) return; -- cgit v1.2.1 From c2b2f0157103c147d4c30a79658f3096e9b68bf1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 11 Dec 2008 11:02:07 +0100 Subject: ctrl + click open new tab AND select --- src/tabwidget.cpp | 1 - src/webview.cpp | 6 ++---- src/webview.h | 1 + 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 58ea75c0..0b815b6e 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -639,7 +639,6 @@ void TabWidget::webViewLoadStarted() int index = webViewIndex(webView); if (-1 != index) { -// QIcon icon(QLatin1String(":loading.gif")); setTabIcon(index, KIcon("rekonq") ); } } diff --git a/src/webview.cpp b/src/webview.cpp index b14b4936..b03c9291 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -63,8 +63,7 @@ BrowserMainWindow *WebPage::mainWindow() bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { - // ctrl open in new tab - // ctrl-shift open in new tab and select + // ctrl open in new tab and select // ctrl-alt open in new window if ( type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) ) @@ -82,8 +81,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r } else { - bool selectNewTab = (m_keyboardModifiers & Qt::ShiftModifier); - webView = mainWindow()->tabWidget()->newTab(selectNewTab); + webView = mainWindow()->tabWidget()->newTab( true ); } webView->load(request); m_keyboardModifiers = Qt::NoModifier; diff --git a/src/webview.h b/src/webview.h index b2e97efb..62d4f3a5 100644 --- a/src/webview.h +++ b/src/webview.h @@ -67,6 +67,7 @@ private: // --------------------------------------------------------------------------------------------------------------------------------------- + class WebView : public QWebView { Q_OBJECT -- cgit v1.2.1 From 72cf5c1727345cca277b36702a59c58b9be5ef58 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 11 Dec 2008 14:34:42 +0100 Subject: ( SHIFT + ) CTRL + TAB switching. Finally!! --- src/browsermainwindow.cpp | 2 +- src/browsermainwindow.h | 3 +-- src/tabwidget.cpp | 4 ++++ src/tabwidget.h | 1 + src/webview.cpp | 20 +++++++++++++++++++- src/webview.h | 11 +++++++++++ 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 3375aa89..ac05a249 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -620,7 +620,7 @@ void BrowserMainWindow::closeEvent(QCloseEvent *event) { int ret = KMessageBox::warningYesNo(this, i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , - QString() ); + i18n("Closing") ); if (ret == KMessageBox::No) { event->ignore(); diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 19ab51c9..9cb9fe18 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -53,9 +53,8 @@ class BrowserMainWindow : public KMainWindow public: BrowserMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~BrowserMainWindow(); - QSize sizeHint() const; -public: + QSize sizeHint() const; static KUrl guessUrlFromString(const QString &url); TabWidget *tabWidget() const; WebView *currentTab() const; diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 0b815b6e..54db660a 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -511,6 +511,10 @@ WebView *TabWidget::newTab(bool makeCurrent) connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); + + connect(webView, SIGNAL( ctrlTabPressed() ), this, SLOT( nextTab() ) ); + connect(webView, SIGNAL( shiftCtrlTabPressed() ), this, SLOT( previousTab() ) ); + addTab(webView, i18n("(Untitled)") ); if (makeCurrent) setCurrentWidget(webView); diff --git a/src/tabwidget.h b/src/tabwidget.h index 27cc4611..72fbc0a7 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -176,6 +176,7 @@ protected: void contextMenuEvent(QContextMenuEvent *event); void mouseReleaseEvent(QMouseEvent *event); + public slots: void loadUrlInCurrentTab(const KUrl &url); WebView *newTab(bool makeCurrent = true); diff --git a/src/webview.cpp b/src/webview.cpp index b03c9291..19bf60ee 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -177,7 +177,6 @@ WebView::WebView(QWidget* parent) connect(page(), SIGNAL(loadingUrl(const QUrl&)), this, SIGNAL(urlChanged(const QUrl &))); connect(page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(downloadRequested(const QNetworkRequest &))); page()->setForwardUnsupportedContent(true); - } @@ -297,3 +296,22 @@ void WebView::downloadRequested(const QNetworkRequest &request) { BrowserApplication::downloadManager()->download(request); } + + +void WebView::keyPressEvent(QKeyEvent *event) +{ + if ( (event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab) ) + { + emit ctrlTabPressed(); + return; + } + + if( (event->modifiers() == Qt::ControlModifier + Qt::ShiftModifier) && (event->key() == Qt::Key_Backtab) ) + { + emit shiftCtrlTabPressed(); + return; + } + + QWebView::keyPressEvent( event ); +} + diff --git a/src/webview.h b/src/webview.h index 62d4f3a5..ae5230ce 100644 --- a/src/webview.h +++ b/src/webview.h @@ -82,12 +82,23 @@ public: QString lastStatusBarText() const; inline int progress() const { return m_progress; } +signals: + // switching tabs + void ctrlTabPressed(); + void shiftCtrlTabPressed(); + protected: void mousePressEvent(QMouseEvent *event); void mouseReleaseEvent(QMouseEvent *event); void contextMenuEvent(QContextMenuEvent *event); void wheelEvent(QWheelEvent *event); + /** + * FIlters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed() + * to make switch tab + */ + void keyPressEvent(QKeyEvent *event); + private slots: void setProgress(int progress); void loadFinished(); -- cgit v1.2.1 From c69985e1cd542a73051c84457e61986a15b7b586 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 12 Dec 2008 11:33:42 +0100 Subject: 1st implementation of colored progress loading urlbar --- src/urlbar.cpp | 43 +++++++++++++++++++++++++++++++++++++++++-- src/urlbar.h | 3 +++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 4a599463..894c702f 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -22,6 +22,7 @@ #include "urlbar.moc" #include "browserapplication.h" +#include "browsermainwindow.h" UrlBar::UrlBar(KHistoryComboBox *parent) @@ -31,25 +32,30 @@ UrlBar::UrlBar(KHistoryComboBox *parent) { m_lineEdit = new QLineEdit; setLineEdit( m_lineEdit ); - + + m_defaultBaseColor = palette().color( QPalette::Base ); + // add every item to history - connect( this, SIGNAL( activated( const QString& )), this, SLOT( addToHistory( const QString& ))); + connect( this, SIGNAL( activated( const QString& ) ), this, SLOT( addToHistory( const QString& ) ) ); webViewIconChanged(); } + UrlBar::~UrlBar() { } + QLineEdit *UrlBar::lineEdit() { return m_lineEdit; } + void UrlBar::setWebView(WebView *webView) { Q_ASSERT(!m_webView); @@ -61,6 +67,7 @@ void UrlBar::setWebView(WebView *webView) } + void UrlBar::webViewUrlChanged(const QUrl &url) { m_lineEdit->setText(url.toString()); @@ -68,6 +75,7 @@ void UrlBar::webViewUrlChanged(const QUrl &url) } + void UrlBar::webViewIconChanged() { KUrl url = (m_webView) ? m_webView->url() : KUrl(); @@ -91,3 +99,34 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const gradient.setColorAt(1, m_defaultBaseColor); return gradient; } + + +void UrlBar::paintEvent( QPaintEvent *event ) +{ + QPalette p = palette(); + if (m_webView && m_webView->url().scheme() == QLatin1String("https")) + { + QColor lightYellow(248, 248, 210); + p.setBrush(QPalette::Base, generateGradient(lightYellow)); + } + else + { + p.setBrush(QPalette::Base, m_defaultBaseColor); + } + setPalette(p); + KHistoryComboBox::paintEvent(event); + + QPainter painter( this ); + QRect backgroundRect = m_lineEdit->frameGeometry(); // contentsRect(); + if ( m_webView && !hasFocus() ) + { + int progress = m_webView->progress(); + QColor loadingColor = QColor(116, 192, 250); + painter.setBrush( generateGradient(loadingColor) ); + painter.setPen(Qt::transparent); + int mid = backgroundRect.width() / 100 * progress; + QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); + painter.drawRect(progressRect); + } +} + diff --git a/src/urlbar.h b/src/urlbar.h index fcebc6f9..a670fca6 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -45,6 +45,9 @@ private slots: void webViewUrlChanged(const QUrl &url); void webViewIconChanged(); +protected: + void paintEvent( QPaintEvent * ); + private: QLinearGradient generateGradient(const QColor &color) const; -- cgit v1.2.1 From 70809c857d125cce1d100e88d7d8ed898669a9ee Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 12 Dec 2008 16:10:04 +0100 Subject: Fixing searchbar dimension && position --- src/searchbar.cpp | 24 +++++++++++++++++++++--- src/searchbar.h | 5 ++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/searchbar.cpp b/src/searchbar.cpp index a48803b3..785fcce5 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -21,9 +21,9 @@ #include "searchbar.h" #include "searchbar.moc" -// Qt Includes -#include -#include +#include "browserapplication.h" +#include "browsermainwindow.h" + SearchBar::SearchBar(QWidget *parent) : QWidget(parent), @@ -50,6 +50,24 @@ SearchBar::~SearchBar() } +void SearchBar::resizeEvent( QResizeEvent * event ) +{ + QRect rect = m_lineEdit->contentsRect(); + + int width = rect.width(); + + int lineEditWidth = BrowserApplication::instance()->mainWindow()->size().width() / 5 ; // FIXME ( OR not?) + + m_lineEdit->setGeometry( rect.x() + ( width - lineEditWidth + 8 ), + rect.y() + 4, + lineEditWidth, + m_lineEdit->height() + ); + + QWidget::resizeEvent( event ); +} + + void SearchBar::searchNow() { QString searchText = m_lineEdit->text(); diff --git a/src/searchbar.h b/src/searchbar.h index 92f20f8e..96ae282a 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -26,7 +26,7 @@ #include // Qt Includes -#include +#include class SearchBar : public QWidget { @@ -41,6 +41,9 @@ public: public slots: void searchNow(); +protected: + void resizeEvent( QResizeEvent *); + private: KLineEdit *m_lineEdit; -- cgit v1.2.1 From 439e23791714ff99876b8cca3afd6225445e75fc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 14 Dec 2008 16:54:45 +0100 Subject: Last changes.. --- src/browsermainwindow.cpp | 33 +++++----------- src/browsermainwindow.h | 3 +- src/urlbar.cpp | 98 +++++++++++++++++++++++++++++------------------ src/urlbar.h | 17 ++++---- 4 files changed, 80 insertions(+), 71 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index ac05a249..e9f685cd 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini @@ -103,7 +103,6 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) } - BrowserMainWindow::~BrowserMainWindow() { m_autoSaver->changeOccurred(); @@ -112,7 +111,6 @@ BrowserMainWindow::~BrowserMainWindow() } - void BrowserMainWindow::loadDefaultState() { KConfig config("rekonqrc"); @@ -122,16 +120,6 @@ void BrowserMainWindow::loadDefaultState() } - -QSize BrowserMainWindow::sizeHint() const -{ - QRect desktopRect = QApplication::desktop()->screenGeometry(); - QSize size = desktopRect.size() * 0.9; - return size; -} - - - void BrowserMainWindow::save() { BrowserApplication::instance()->saveSession(); @@ -143,11 +131,9 @@ void BrowserMainWindow::save() } - static const qint32 BrowserMainWindowMagic = 0xba; - QByteArray BrowserMainWindow::saveState(bool withTabs) const { int version = 2; @@ -208,7 +194,6 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) } - void BrowserMainWindow::setupMenu() { // ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- @@ -367,7 +352,11 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { - m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, true, false, false); + m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, false); + + // UI settings + m_navigationBar->setContextMenuPolicy( Qt::NoContextMenu ); + m_navigationBar->setIconDimensions(22); m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); @@ -390,14 +379,12 @@ void BrowserMainWindow::setupToolBar() m_navigationBar->addWidget( m_tabWidget->lineEditStack() ); - m_searchBar = new SearchBar(m_navigationBar); - m_navigationBar->addWidget(m_searchBar); + m_searchBar = new SearchBar( this ); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + m_navigationBar->addWidget(m_searchBar); - // UI settings - m_navigationBar->setIconDimensions(16); - m_navigationBar->setContextMenuPolicy( Qt::NoContextMenu ); - KToolBar::setToolBarsLocked( true ); +// KToolBar::setToolBarsEditable( false ); +// KToolBar::setToolBarsLocked( true ); } diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index 9cb9fe18..d50abcc4 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini @@ -54,7 +54,6 @@ public: BrowserMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~BrowserMainWindow(); - QSize sizeHint() const; static KUrl guessUrlFromString(const QString &url); TabWidget *tabWidget() const; WebView *currentTab() const; diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 894c702f..85e59693 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * @@ -25,18 +25,25 @@ #include "browsermainwindow.h" -UrlBar::UrlBar(KHistoryComboBox *parent) - : KHistoryComboBox(true, parent) +UrlBar::UrlBar(QWidget *parent) + : QWidget(parent) + , m_historyComboBox( new KHistoryComboBox( true, parent ) ) , m_webView(0) - , m_lineEdit(0) + , m_lineEdit(new QLineEdit) { - m_lineEdit = new QLineEdit; - setLineEdit( m_lineEdit ); + m_historyComboBox->setLineEdit( m_lineEdit ); + + QSizePolicy policy = sizePolicy(); + setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget( m_historyComboBox ); + setLayout(layout); m_defaultBaseColor = palette().color( QPalette::Base ); // add every item to history - connect( this, SIGNAL( activated( const QString& ) ), this, SLOT( addToHistory( const QString& ) ) ); + connect( m_historyComboBox, SIGNAL( activated( const QString& ) ), m_historyComboBox, SLOT( addToHistory( const QString& ) ) ); webViewIconChanged(); } @@ -84,8 +91,8 @@ void UrlBar::webViewIconChanged() QIcon urlIcon = QIcon(pixmap); // FIXME simple hack to show Icon in the urlbar, as calling changeUrl() doesn't affect it - removeItem( 0 ); - insertUrl( 0 , urlIcon , url ); + m_historyComboBox->removeItem( 0 ); + m_historyComboBox->insertUrl( 0 , urlIcon , url ); } @@ -101,32 +108,47 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const } -void UrlBar::paintEvent( QPaintEvent *event ) -{ - QPalette p = palette(); - if (m_webView && m_webView->url().scheme() == QLatin1String("https")) - { - QColor lightYellow(248, 248, 210); - p.setBrush(QPalette::Base, generateGradient(lightYellow)); - } - else - { - p.setBrush(QPalette::Base, m_defaultBaseColor); - } - setPalette(p); - KHistoryComboBox::paintEvent(event); - - QPainter painter( this ); - QRect backgroundRect = m_lineEdit->frameGeometry(); // contentsRect(); - if ( m_webView && !hasFocus() ) - { - int progress = m_webView->progress(); - QColor loadingColor = QColor(116, 192, 250); - painter.setBrush( generateGradient(loadingColor) ); - painter.setPen(Qt::transparent); - int mid = backgroundRect.width() / 100 * progress; - QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); - painter.drawRect(progressRect); - } -} - +// void UrlBar::paintEvent( QPaintEvent *event ) +// { +// QPalette p = palette(); +// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) +// { +// QColor lightYellow(248, 248, 210); +// p.setBrush(QPalette::Base, generateGradient(lightYellow)); +// } +// else +// { +// p.setBrush(QPalette::Base, m_defaultBaseColor); +// } +// setPalette(p); +// KHistoryComboBox::paintEvent(event); +// +// QPainter painter( this ); +// QRect backgroundRect = m_lineEdit->frameGeometry(); // contentsRect(); // FIXME perhaps better working with contentsRect +// if ( m_webView && !hasFocus() ) // and modifying colours.. +// { +// int progress = m_webView->progress(); +// QColor loadingColor = QColor(116, 192, 250); +// painter.setBrush( generateGradient(loadingColor) ); +// painter.setPen(Qt::transparent); +// int mid = backgroundRect.width() / 100 * progress; +// QRect progressRect(backgroundRect.x(), backgroundRect.y(), mid, backgroundRect.height()); +// painter.drawRect(progressRect); +// } +// } + + +// void UrlBar::resizeEvent( QResizeEvent *event ) +// { +// QRect rect = m_historyComboBox->frameGeometry(); +// +// int newWidth = BrowserApplication::instance()->mainWindow()->size().width() * 3 / 5 ; // FIXME ( OR not?) +// +// m_historyComboBox->setGeometry( rect.x(), +// rect.y(), +// newWidth, +// m_historyComboBox->height() +// ); +// +// QWidget::resizeEvent( event ); +// } diff --git a/src/urlbar.h b/src/urlbar.h index a670fca6..3180920a 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * @@ -30,12 +30,12 @@ #include -class UrlBar : public KHistoryComboBox +class UrlBar : public QWidget { Q_OBJECT public: - UrlBar(KHistoryComboBox *parent = 0); + UrlBar(QWidget *parent = 0); ~UrlBar(); QLineEdit *lineEdit(); @@ -46,15 +46,16 @@ private slots: void webViewIconChanged(); protected: - void paintEvent( QPaintEvent * ); +// void paintEvent( QPaintEvent * ); +// void resizeEvent( QResizeEvent * ); private: QLinearGradient generateGradient(const QColor &color) const; - WebView *m_webView; - - QLineEdit *m_lineEdit; - QColor m_defaultBaseColor; + KHistoryComboBox* m_historyComboBox; + WebView* m_webView; + QLineEdit* m_lineEdit; + QColor m_defaultBaseColor; }; #endif -- cgit v1.2.1 From 19e901a0ca9630b2003dd24ccfa6da54eb70bb09 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 14 Dec 2008 18:27:17 +0100 Subject: adjusted rekonq name commented out (hopefully, for now) resizeEvents and focusInEvents in urlbar & searchbar --- src/autosaver.cpp | 2 +- src/autosaver.h | 2 +- src/bookmarks.cpp | 4 ++-- src/bookmarks.h | 2 +- src/browserapplication.cpp | 2 +- src/browserapplication.h | 2 +- src/browsermainwindow.cpp | 4 ++-- src/cookiejar.cpp | 2 +- src/cookiejar.h | 2 +- src/downloadmanager.cpp | 2 +- src/downloadmanager.h | 2 +- src/edittableview.cpp | 2 +- src/edittableview.h | 2 +- src/edittreeview.cpp | 2 +- src/edittreeview.h | 2 +- src/findbar.cpp | 2 +- src/findbar.h | 2 +- src/history.cpp | 2 +- src/history.h | 2 +- src/main.cpp | 10 +++++----- src/modelmenu.cpp | 2 +- src/modelmenu.h | 2 +- src/networkaccessmanager.cpp | 2 +- src/networkaccessmanager.h | 2 +- src/searchbar.cpp | 46 +++++++++++++++++++++++++------------------- src/searchbar.h | 7 +++++-- src/settings.cpp | 2 +- src/settings.h | 2 +- src/squeezelabel.cpp | 2 +- src/squeezelabel.h | 2 +- src/tabwidget.cpp | 2 +- src/tabwidget.h | 2 +- src/webview.cpp | 2 +- src/webview.h | 2 +- 34 files changed, 69 insertions(+), 60 deletions(-) diff --git a/src/autosaver.cpp b/src/autosaver.cpp index c1164e60..965d550b 100644 --- a/src/autosaver.cpp +++ b/src/autosaver.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/autosaver.h b/src/autosaver.h index 70dca53a..c202bb70 100644 --- a/src/autosaver.h +++ b/src/autosaver.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index e03bf3dc..ec46dd53 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * @@ -51,7 +51,7 @@ QString OwnBookMarks::currentUrl() const QString OwnBookMarks::currentTitle() const { QString title = m_parent->windowTitle(); - return title.remove( " - reKonq" ); + return title.remove( " - rekonq" ); } diff --git a/src/bookmarks.h b/src/bookmarks.h index 950fc8a6..91160321 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 8a1ffc5a..52c5e670 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/browserapplication.h b/src/browserapplication.h index eb6962ef..7f2ef321 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index e9f685cd..7b6bfc05 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -506,9 +506,9 @@ void BrowserMainWindow::slotUpdateStatusbar(const QString &string) void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) { if (title.isEmpty()) { - setWindowTitle("reKonq"); + setWindowTitle("rekonq"); } else { - setWindowTitle(title + " - reKonq"); + setWindowTitle(title + " - rekonq"); } } diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index 396052b9..b513f88a 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/cookiejar.h b/src/cookiejar.h index d3843c51..835700f1 100644 --- a/src/cookiejar.h +++ b/src/cookiejar.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 7584f36a..df990c7b 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 89981641..1a2e5d30 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/edittableview.cpp b/src/edittableview.cpp index 5f60721a..17a01ecc 100644 --- a/src/edittableview.cpp +++ b/src/edittableview.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/edittableview.h b/src/edittableview.h index 48d60d2a..3c2c69db 100644 --- a/src/edittableview.h +++ b/src/edittableview.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/edittreeview.cpp b/src/edittreeview.cpp index e01843f8..e3f79fc3 100644 --- a/src/edittreeview.cpp +++ b/src/edittreeview.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/edittreeview.h b/src/edittreeview.h index b4a46b6f..fd995b47 100644 --- a/src/edittreeview.h +++ b/src/edittreeview.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/findbar.cpp b/src/findbar.cpp index 14d52001..b45dc8fa 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * diff --git a/src/findbar.h b/src/findbar.h index 4c0034a6..f8ef183e 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * diff --git a/src/history.cpp b/src/history.cpp index 930e73ae..5466963b 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/history.h b/src/history.h index 41763b69..acd27192 100644 --- a/src/history.h +++ b/src/history.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/main.cpp b/src/main.cpp index 304c2301..e2f74b4d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini @@ -29,9 +29,9 @@ int main(int argc, char **argv) { KAboutData aboutData( - "reKonq", + "rekonq", 0, - ki18n("reKonq"), + ki18n("rekonq"), "0.0.1", ki18n("A KDE browser webkit based"), KAboutData::License_GPL, @@ -41,7 +41,7 @@ int main(int argc, char **argv) "adjam7@gmail.com" // bug report mail ); - aboutData.addAuthor(ki18n("Andrea Diamantini"), ki18n("reKonq author"), "adjam7@gmail.com"); + aboutData.addAuthor(ki18n("Andrea Diamantini"), ki18n("rekonq author"), "adjam7@gmail.com"); aboutData.setProgramIconName("applications-internet"); KCmdLineArgs::init( argc, argv, &aboutData ); @@ -52,7 +52,7 @@ int main(int argc, char **argv) KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - BrowserApplication app(args, "reKonq"); + BrowserApplication app(args, "rekonq"); if (!app.isTheOnlyBrowser()) return 0; app.newMainWindow(); diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp index 7c8fb128..f2cd0189 100644 --- a/src/modelmenu.cpp +++ b/src/modelmenu.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/modelmenu.h b/src/modelmenu.h index 61ec370b..fe08e673 100644 --- a/src/modelmenu.h +++ b/src/modelmenu.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index c5967d2a..869a6144 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index 45ef1b0d..7d683967 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 785fcce5..29862e6d 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * @@ -27,11 +27,17 @@ SearchBar::SearchBar(QWidget *parent) : QWidget(parent), - m_lineEdit(0) + m_lineEdit(new KLineEdit) { - m_lineEdit = new KLineEdit(this); m_lineEdit->setClearButtonShown( true ); + m_lineEdit->setFocusProxy( this ); + setFocusPolicy( Qt::WheelFocus ); + setMouseTracking( true ); + + QSizePolicy policy = sizePolicy(); + setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); + QPalette palette; palette.setColor( QPalette::Text, Qt::gray ); m_lineEdit->setPalette( palette ); @@ -41,7 +47,7 @@ SearchBar::SearchBar(QWidget *parent) : layout->addWidget(m_lineEdit); setLayout(layout); - connect( lineEdit() , SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); + connect( m_lineEdit , SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); } @@ -50,22 +56,22 @@ SearchBar::~SearchBar() } -void SearchBar::resizeEvent( QResizeEvent * event ) -{ - QRect rect = m_lineEdit->contentsRect(); - - int width = rect.width(); - - int lineEditWidth = BrowserApplication::instance()->mainWindow()->size().width() / 5 ; // FIXME ( OR not?) - - m_lineEdit->setGeometry( rect.x() + ( width - lineEditWidth + 8 ), - rect.y() + 4, - lineEditWidth, - m_lineEdit->height() - ); - - QWidget::resizeEvent( event ); -} +// void SearchBar::resizeEvent( QResizeEvent * event ) +// { +// QRect rect = m_lineEdit->contentsRect(); +// +// int width = rect.width(); +// +// int lineEditWidth = BrowserApplication::instance()->mainWindow()->size().width() / 5 ; // FIXME ( OR not?) +// +// m_lineEdit->setGeometry( rect.x() + ( width - lineEditWidth + 8 ), +// rect.y() + 4, +// lineEditWidth, +// m_lineEdit->height() +// ); +// +// QWidget::resizeEvent( event ); +// } void SearchBar::searchNow() diff --git a/src/searchbar.h b/src/searchbar.h index 96ae282a..67f2bda5 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini  * @@ -38,11 +38,14 @@ public: KLineEdit *lineEdit(); + friend class KLineEdit; + public slots: void searchNow(); protected: - void resizeEvent( QResizeEvent *); +// void resizeEvent(QResizeEvent *); +// void focusInEvent(QFocusEvent *); private: KLineEdit *m_lineEdit; diff --git a/src/settings.cpp b/src/settings.cpp index 74376ea8..2562530d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/settings.h b/src/settings.h index 9b452610..4c99cd98 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/squeezelabel.cpp b/src/squeezelabel.cpp index 334219df..7aa9e177 100644 --- a/src/squeezelabel.cpp +++ b/src/squeezelabel.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/squeezelabel.h b/src/squeezelabel.h index 7baee5f5..a7906270 100644 --- a/src/squeezelabel.h +++ b/src/squeezelabel.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 54db660a..46724e1e 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/tabwidget.h b/src/tabwidget.h index 72fbc0a7..1a46371c 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/webview.cpp b/src/webview.cpp index 19bf60ee..dd28124a 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini diff --git a/src/webview.h b/src/webview.h index ae5230ce..aa8efb81 100644 --- a/src/webview.h +++ b/src/webview.h @@ -1,6 +1,6 @@ /* ============================================================  * - * This file is a part of the reKonq project + * This file is a part of the rekonq project  * * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini -- cgit v1.2.1 From 3b46e82683bbac9f2bfc355dafae7408f72231b0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 14 Dec 2008 19:27:23 +0100 Subject: Some improvements in settings class.. --- src/settings.cpp | 37 ++++++++++++++++++------------------- src/settings.h | 5 ++--- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 2562530d..355799bd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -39,10 +39,9 @@ #include SettingsDialog::SettingsDialog(QWidget *parent) - : KDialog(parent), - widget(0) + : KDialog(parent) { - widget = new QWidget; + QWidget *widget = new QWidget; setupUi(widget); @@ -72,13 +71,13 @@ void SettingsDialog::loadDefaults() QWebSettings *defaultSettings = QWebSettings::globalSettings(); QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); - standardFont = QFont(standardFontFamily, standardFontSize); - standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); + m_standardFont = QFont(standardFontFamily, standardFontSize); + standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() )); QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); - fixedFont = QFont(fixedFontFamily, fixedFontSize); - fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); + m_fixedFont = QFont(fixedFontFamily, fixedFontSize); + fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); downloadsLocation->setText(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); @@ -118,11 +117,11 @@ void SettingsDialog::loadFromSettings() // Appearance KConfigGroup group2 = config.group("Appearance Settings"); - fixedFont = group2.readEntry( QString("fixedFont"), fixedFont ); - standardFont = group2.readEntry( QString("standardFont"), standardFont ); + m_fixedFont = group2.readEntry( QString("fixedFont"), m_fixedFont ); + m_standardFont = group2.readEntry( QString("standardFont"), m_standardFont ); - standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); - fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); + standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); + fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); enableJavascript->setChecked( group2.readEntry( QString("enableJavascript"), enableJavascript->isChecked() ) ); enablePlugins->setChecked( group2.readEntry( QString("enablePlugins"), enablePlugins->isChecked() ) ); @@ -202,8 +201,8 @@ void SettingsDialog::saveToSettings() group1.writeEntry(QString("historyExpire"), idx ); KConfigGroup group2 = config.group("Appearance Settings"); - group2.writeEntry(QString("fixedFont"),fixedFont); - group2.writeEntry(QString("standardFont"), standardFont); + group2.writeEntry(QString("fixedFont"), m_fixedFont); + group2.writeEntry(QString("standardFont"), m_standardFont); KConfigGroup group3 = config.group("Privacy Settings"); group3.writeEntry(QString("enableJavascript"), enableJavascript->isChecked() ); @@ -280,12 +279,12 @@ void SettingsDialog::showExceptions() void SettingsDialog::chooseFont() { - QFont myFont; + QFont myFont( m_standardFont ); int result = KFontDialog::getFont( myFont ); if ( result == KFontDialog::Accepted ) { - standardFont = myFont; - standardLabel->setText(QString(QLatin1String("%1 %2")).arg(standardFont.family()).arg(standardFont.pointSize())); + m_standardFont = myFont; + standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); } } @@ -293,12 +292,12 @@ void SettingsDialog::chooseFont() void SettingsDialog::chooseFixedFont() { - QFont myFont; + QFont myFont( m_fixedFont ); int result = KFontDialog::getFont( myFont , KFontChooser::FixedFontsOnly ); if ( result == KFontDialog::Accepted ) { - fixedFont = myFont; - fixedLabel->setText(QString(QLatin1String("%1 %2")).arg(fixedFont.family()).arg(fixedFont.pointSize())); + m_fixedFont = myFont; + fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); } } diff --git a/src/settings.h b/src/settings.h index 4c99cd98..39845c63 100644 --- a/src/settings.h +++ b/src/settings.h @@ -53,9 +53,8 @@ private slots: void slotApply(); private: - QFont standardFont; - QFont fixedFont; - QWidget *widget; + QFont m_standardFont; + QFont m_fixedFont; }; #endif // SETTINGS_H -- cgit v1.2.1 From af9623896acb241a965a7d0823e12fd099031a39 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 16 Dec 2008 01:09:39 +0100 Subject: Initial solution for UI resizing.. Now we can release rekonq 0.0.2 and thinking later about the problem.. --- src/browsermainwindow.cpp | 14 ++++++------- src/searchbar.cpp | 51 ++++++++++++++++------------------------------- src/searchbar.h | 14 +++---------- src/tabwidget.cpp | 3 ++- src/urlbar.cpp | 37 ++++++++++++++++------------------ src/urlbar.h | 3 +-- 6 files changed, 47 insertions(+), 75 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 7b6bfc05..60115b09 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -354,10 +354,6 @@ void BrowserMainWindow::setupToolBar() { m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, false); - // UI settings - m_navigationBar->setContextMenuPolicy( Qt::NoContextMenu ); - m_navigationBar->setIconDimensions(22); - m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); m_historyBack->setMenu(m_historyBackMenu); @@ -379,12 +375,16 @@ void BrowserMainWindow::setupToolBar() m_navigationBar->addWidget( m_tabWidget->lineEditStack() ); - m_searchBar = new SearchBar( this ); + m_searchBar = new SearchBar( m_navigationBar ); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); m_navigationBar->addWidget(m_searchBar); -// KToolBar::setToolBarsEditable( false ); -// KToolBar::setToolBarsLocked( true ); + // UI settings + setContextMenuPolicy( Qt::PreventContextMenu ); + m_navigationBar->setIconDimensions(22); + + KToolBar::setToolBarsEditable( false ); + KToolBar::setToolBarsLocked( true ); } diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 29862e6d..0cf8e801 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -26,28 +26,24 @@ SearchBar::SearchBar(QWidget *parent) : - QWidget(parent), - m_lineEdit(new KLineEdit) + KLineEdit(parent) { - m_lineEdit->setClearButtonShown( true ); - - m_lineEdit->setFocusProxy( this ); + setMinimumWidth(180); setFocusPolicy( Qt::WheelFocus ); setMouseTracking( true ); + setAcceptDrops(true); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); - QPalette palette; - palette.setColor( QPalette::Text, Qt::gray ); - m_lineEdit->setPalette( palette ); - m_lineEdit->setText( "Search.." ); + setClearButtonShown( true ); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(m_lineEdit); - setLayout(layout); + QPalette p; + p.setColor( QPalette::Text , Qt::lightGray ); + setPalette( p ); + setText( i18n("Search..") ); - connect( m_lineEdit , SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); + connect( this, SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); } @@ -56,27 +52,9 @@ SearchBar::~SearchBar() } -// void SearchBar::resizeEvent( QResizeEvent * event ) -// { -// QRect rect = m_lineEdit->contentsRect(); -// -// int width = rect.width(); -// -// int lineEditWidth = BrowserApplication::instance()->mainWindow()->size().width() / 5 ; // FIXME ( OR not?) -// -// m_lineEdit->setGeometry( rect.x() + ( width - lineEditWidth + 8 ), -// rect.y() + 4, -// lineEditWidth, -// m_lineEdit->height() -// ); -// -// QWidget::resizeEvent( event ); -// } - - void SearchBar::searchNow() { - QString searchText = m_lineEdit->text(); + QString searchText = text(); KUrl url(QLatin1String("http://www.google.com/search")); url.addQueryItem(QLatin1String("q"), searchText); @@ -87,8 +65,13 @@ void SearchBar::searchNow() } -KLineEdit *SearchBar::lineEdit() +void SearchBar::focusInEvent(QFocusEvent *event) { - return m_lineEdit; + KLineEdit::focusInEvent(event); + + QPalette p; + p.setColor( QPalette::Text , Qt::black ); + setPalette( p ); + clear(); } diff --git a/src/searchbar.h b/src/searchbar.h index 67f2bda5..a83d7024 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -28,27 +28,19 @@ // Qt Includes #include -class SearchBar : public QWidget +class SearchBar : public KLineEdit { -Q_OBJECT + Q_OBJECT public: SearchBar(QWidget *parent = 0); ~SearchBar(); - KLineEdit *lineEdit(); - - friend class KLineEdit; - public slots: void searchNow(); protected: -// void resizeEvent(QResizeEvent *); -// void focusInEvent(QFocusEvent *); - -private: - KLineEdit *m_lineEdit; + void focusInEvent(QFocusEvent * ); signals: void search(const KUrl &url); diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 46724e1e..24aacfff 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -41,6 +41,7 @@ TabBar::TabBar(QWidget *parent) : KTabBar(parent) { + setElideMode(Qt::ElideRight); setContextMenuPolicy(Qt::CustomContextMenu); setAcceptDrops(true); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); @@ -495,7 +496,7 @@ WebView *TabWidget::newTab(bool makeCurrent) connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); return 0; } - + // webview WebView *webView = new WebView; urlLineEdit->setWebView(webView); diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 85e59693..e2dc458d 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -26,24 +26,19 @@ UrlBar::UrlBar(QWidget *parent) - : QWidget(parent) - , m_historyComboBox( new KHistoryComboBox( true, parent ) ) + : KHistoryComboBox( true, parent ) , m_webView(0) , m_lineEdit(new QLineEdit) { - m_historyComboBox->setLineEdit( m_lineEdit ); + setLineEdit( m_lineEdit ); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget( m_historyComboBox ); - setLayout(layout); - m_defaultBaseColor = palette().color( QPalette::Base ); // add every item to history - connect( m_historyComboBox, SIGNAL( activated( const QString& ) ), m_historyComboBox, SLOT( addToHistory( const QString& ) ) ); + connect( this, SIGNAL( activated( const QString& ) ), this, SLOT( addToHistory( const QString& ) ) ); webViewIconChanged(); } @@ -91,8 +86,8 @@ void UrlBar::webViewIconChanged() QIcon urlIcon = QIcon(pixmap); // FIXME simple hack to show Icon in the urlbar, as calling changeUrl() doesn't affect it - m_historyComboBox->removeItem( 0 ); - m_historyComboBox->insertUrl( 0 , urlIcon , url ); + removeItem( 0 ); + insertUrl( 0 , urlIcon , url ); } @@ -138,17 +133,19 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const // } -// void UrlBar::resizeEvent( QResizeEvent *event ) +// FIXME : seems working. Need to re-enable it when searchbar resizing will work , too.. +// void UrlBar::resizeEvent( QResizeEvent * event ) // { -// QRect rect = m_historyComboBox->frameGeometry(); -// -// int newWidth = BrowserApplication::instance()->mainWindow()->size().width() * 3 / 5 ; // FIXME ( OR not?) +// QRect rect = geometry(); // -// m_historyComboBox->setGeometry( rect.x(), -// rect.y(), -// newWidth, -// m_historyComboBox->height() -// ); +// int windowWidth = BrowserApplication::instance()->mainWindow()->size().width() ; // FIXME ( OR not?) +// int newWidth = windowWidth * 4 / 6; +// +// setGeometry( rect.x() + 1, +// rect.y() + 1, +// newWidth, +// height() +// ); // -// QWidget::resizeEvent( event ); +// KHistoryComboBox::resizeEvent( event ); // } diff --git a/src/urlbar.h b/src/urlbar.h index 3180920a..1346eada 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -30,7 +30,7 @@ #include -class UrlBar : public QWidget +class UrlBar : public KHistoryComboBox { Q_OBJECT @@ -52,7 +52,6 @@ protected: private: QLinearGradient generateGradient(const QColor &color) const; - KHistoryComboBox* m_historyComboBox; WebView* m_webView; QLineEdit* m_lineEdit; QColor m_defaultBaseColor; -- cgit v1.2.1 From dd77666f0f27e52b67ae001a60717ec0c455430e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 16 Dec 2008 01:59:36 +0100 Subject: Updated TODO --- TODO | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 2991ac44..09b201f6 100644 --- a/TODO +++ b/TODO @@ -4,19 +4,29 @@ Road to 0.0.1 (first release) + bookmarks (share konqueror's) + some porting +0.0.2 ++ QUrl --> KUrl ++ KDEize menubar (settings) ++ new urlbar & searchbar (for now just Google search bar..) + + NEXT.. - Fixing QByteArray save/load state!! - system SELECT ALL - better FULL SCREEN - simplify history -+ QUrl --> KUrl - KDE download = Kjob && Kget -- adjust toolbar(s) - -search bar - - url bar -+ KDEize menubar (settings) - configure dialog (A-LA amarok, konqueror) - dbus support (?!) - KWallet support - Kpart ?? + ++------------------------ + +- Kconfig::gloabl : investigate. +- contextMenu in searchbar to set different search engines +- save toolbars settings +- NEW save/load setting functions in KMainWIndow +- improve CMakeLists.txt 4.4 required, 4.5 better.. +- browse code to search TODO and FIXME -- cgit v1.2.1 From 16432de65c59318d4b4c8cadb6d4a366d851d973 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 16 Dec 2008 02:00:24 +0100 Subject: Some other steps on the road to the KDE browser.. --- src/browsermainwindow.cpp | 1 - src/urlbar.cpp | 17 ----------------- src/urlbar.h | 2 +- src/webview.cpp | 12 ++++++++---- 4 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 60115b09..8a936774 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -342,7 +342,6 @@ void BrowserMainWindow::setupMenu() // ------------------------------------------------------------- SETTINGS ------------------------------------------------------------------------------------------------------ KMenu *settingsMenu = (KMenu *) menuBar()->addMenu( i18n("&Settings") ); -// TODO settingsMenu->addAction( KStandardAction::configureToolbars(this, SLOT( ) , this ) ); settingsMenu->addAction( KStandardAction::preferences(this, SLOT( slotPreferences() ) , this ) ); // ------------------------------------------------------------- HELP -------------------------------------------------------------------------------------------------- diff --git a/src/urlbar.cpp b/src/urlbar.cpp index e2dc458d..bd84b6d5 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -132,20 +132,3 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const // } // } - -// FIXME : seems working. Need to re-enable it when searchbar resizing will work , too.. -// void UrlBar::resizeEvent( QResizeEvent * event ) -// { -// QRect rect = geometry(); -// -// int windowWidth = BrowserApplication::instance()->mainWindow()->size().width() ; // FIXME ( OR not?) -// int newWidth = windowWidth * 4 / 6; -// -// setGeometry( rect.x() + 1, -// rect.y() + 1, -// newWidth, -// height() -// ); -// -// KHistoryComboBox::resizeEvent( event ); -// } diff --git a/src/urlbar.h b/src/urlbar.h index 1346eada..99199d9c 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -47,7 +47,7 @@ private slots: protected: // void paintEvent( QPaintEvent * ); -// void resizeEvent( QResizeEvent * ); + private: QLinearGradient generateGradient(const QColor &color) const; diff --git a/src/webview.cpp b/src/webview.cpp index dd28124a..f836b5ea 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -180,21 +180,25 @@ WebView::WebView(QWidget* parent) } +// TODO : improve and KDE-ize this menu void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); if (!r.linkUrl().isEmpty()) { - QMenu menu(this); - menu.addAction(pageAction(QWebPage::OpenLinkInNewWindow)); - menu.addAction(i18n("Open in New Tab"), this, SLOT(openLinkInNewTab())); + KMenu menu(this); + KAction *a = new KAction( KIcon("tab-new"), i18n("Open in New Tab"), this); + connect( a, SIGNAL( triggered() ), this , SLOT( openLinkInNewTab() ) ); + menu.addAction( a ); menu.addSeparator(); menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); // Add link to bookmarks... menu.addSeparator(); menu.addAction(pageAction(QWebPage::CopyLinkToClipboard)); - if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) + if ( page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled) ) + { menu.addAction(pageAction(QWebPage::InspectElement)); + } menu.exec(mapToGlobal(event->pos())); return; } -- cgit v1.2.1 From cc1049c1dcc500ef6f8e650e9add97614f3a37b2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 17 Dec 2008 01:31:30 +0100 Subject: Enhanced CMakeLists.txt --- CMakeLists.txt | 90 +++++++++++++++++++++++++++++++++++++++++++++++++--------- TODO | 3 ++ 2 files changed, 80 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4de5473..532f39b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,23 +3,87 @@ PROJECT( rekonq ) +# =============================================================================================== +# Informations to update before to release this package. + +# rekonq version +SET(REKONQ_MAJOR_VERSION "0") +SET(REKONQ_MINOR_VERSION "0") +SET(REKONQ_PATCH_VERSION "1") + +SET(REKONQ_VERSION_STRING + "${REKONQ_MAJOR_VERSION}.${REKONQ_MINOR_VERSION}.${REKONQ_PATCH_VERSION}" + ) + +# ================================================================================================= +# minimum cmake required + CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) +# ================================================================================================= + + SET( QT_MIN_VERSION 4.4.0) -FIND_PACKAGE( KDE4 REQUIRED ) +FIND_PACKAGE(KDE4 REQUIRED) +INCLUDE(MacroOptionalFindPackage) +INCLUDE(FindPackageHandleStandardArgs) INCLUDE(KDE4Defaults) INCLUDE(MacroLibrary) -INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${KDE4_INCLUDES} - ${QT4_INCLUDES} - ${QT_QTNETWORK_INCLUDE_DIR} - ${QT_QTWEBKIT_INCLUDE_DIR} -) - -ADD_SUBDIRECTORY( src ) -ADD_SUBDIRECTORY( icons ) -ADD_SUBDIRECTORY( data ) -ADD_SUBDIRECTORY( htmls ) +# ================================================================================================== +# Log messages + +MESSAGE(STATUS "") +MESSAGE(STATUS "----------------------------------------------------------------------------------") +MESSAGE(STATUS " rekonq ${REKONQ_VERSION_STRING} dependencies results ") +MESSAGE(STATUS "") + +# Require shared libraries results. + +IF(QT_FOUND) + MESSAGE(STATUS " qt library found............... YES") +ELSE(QT_FOUND) + MESSAGE(STATUS " qt library found............... NO") + MESSAGE(STATUS "") + MESSAGE(SEND_ERROR " rekonq needs at least Qt 4.4.0. Please install it and try compiling again.") + MESSAGE(STATUS " Qt website is at http://www.trolltech.com") + MESSAGE(STATUS "") +ENDIF(QT_FOUND) + +MESSAGE(STATUS "----------------------------------------------------------------------------------") +MESSAGE(STATUS "") + +# Optional plugins results. + +IF(QT_FOUND) + MESSAGE(STATUS " rekonq will be compiled....... YES") + SET(REKONQ_CAN_BE_COMPILED true) +ELSE(QT_FOUND) + MESSAGE(FATAL_ERROR " rekonq will not be compiled!") + SET(REKONQ_CAN_BE_COMPILED false) +ENDIF(QT_FOUND) + +MESSAGE(STATUS "----------------------------------------------------------------------------------") +MESSAGE(STATUS "") + +# ================================================================================================== + +IF(REKONQ_CAN_BE_COMPILED) + + INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${KDE4_INCLUDES} + ${QT4_INCLUDES} + ${QT_QTNETWORK_INCLUDE_DIR} + ${QT_QTWEBKIT_INCLUDE_DIR} + ) + + ADD_SUBDIRECTORY( src ) + ADD_SUBDIRECTORY( icons ) + ADD_SUBDIRECTORY( data ) + ADD_SUBDIRECTORY( htmls ) + +ENDIF(REKONQ_CAN_BE_COMPILED) + +# ===================================================================================================== \ No newline at end of file diff --git a/TODO b/TODO index 09b201f6..dc11984b 100644 --- a/TODO +++ b/TODO @@ -30,3 +30,6 @@ NEXT.. - NEW save/load setting functions in KMainWIndow - improve CMakeLists.txt 4.4 required, 4.5 better.. - browse code to search TODO and FIXME +- qDebug --> kWarning() / kDebug()! +- dbus support + -- cgit v1.2.1 From 3fcb4e226ebe126f6c3a289d34f1b6a83c1444c1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 17 Dec 2008 02:03:21 +0100 Subject: qDebug && qWarning --> kDebug && kWarning --- TODO | 1 - src/autosaver.cpp | 14 ++++++++++---- src/cookiejar.cpp | 6 +++--- src/history.cpp | 16 ++++++++-------- src/webview.cpp | 2 +- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/TODO b/TODO index dc11984b..a357e0c7 100644 --- a/TODO +++ b/TODO @@ -24,7 +24,6 @@ NEXT.. +------------------------ -- Kconfig::gloabl : investigate. - contextMenu in searchbar to set different search engines - save toolbars settings - NEW save/load setting functions in KMainWIndow diff --git a/src/autosaver.cpp b/src/autosaver.cpp index 965d550b..535d8a2b 100644 --- a/src/autosaver.cpp +++ b/src/autosaver.cpp @@ -18,10 +18,15 @@  *  * ============================================================ */ +// Local Includes #include "autosaver.h" +// KDE Includes +#include + +// Qt Includes #include -#include + #define AUTOSAVE_IN 1000 * 3 // seconds #define MAXWAIT 1000 * 15 // seconds @@ -36,7 +41,7 @@ AutoSaver::AutoSaver(QObject *parent) : QObject(parent) AutoSaver::~AutoSaver() { if (m_timer.isActive()) - qWarning() << "AutoSaver: still active when destroyed, changes not saved."; + kWarning() << "AutoSaver: still active when destroyed, changes not saved."; } @@ -69,8 +74,9 @@ void AutoSaver::saveIfNeccessary() return; m_timer.stop(); m_firstChange = QTime(); - if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) { - qWarning() << "AutoSaver: error invoking slot save() on parent"; + if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) + { + kWarning() << "AutoSaver: error invoking slot save() on parent"; } } diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index b513f88a..87d84def 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -26,13 +26,13 @@ // KDE Includes #include #include +#include // Qt Includes #include #include #include -#include static const unsigned int JAR_VERSION = 23; @@ -65,7 +65,7 @@ QDataStream &operator>>(QDataStream &stream, QList &list) QList newCookies = QNetworkCookie::parseCookies(value); if (newCookies.count() == 0 && value.length() != 0) { - qWarning() << "CookieJar: Unable to parse saved cookie:" << value; + kWarning() << "CookieJar: Unable to parse saved cookie:" << value; } for (int j = 0; j < newCookies.count(); ++j) list.append(newCookies.at(j)); @@ -282,7 +282,7 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const } #if 0 else - qWarning() << "setCookiesFromUrl failed" << url << cookieList.value(0).toRawForm(); + kWarning() << "setCookiesFromUrl failed" << url << cookieList.value(0).toRawForm(); #endif } } diff --git a/src/history.cpp b/src/history.cpp index 5466963b..36a710b1 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -24,16 +24,16 @@ #include "autosaver.h" #include "browserapplication.h" +// KDE Includes +#include +#include + // Qt Includes #include #include #include #include -#include - -// KDE Includes -#include static const unsigned int HISTORY_VERSION = 23; @@ -235,7 +235,7 @@ void HistoryManager::load() return; if (!historyFile.open(QFile::ReadOnly)) { - qWarning() << "Unable to open history file" << historyFile.fileName(); + kWarning() << "Unable to open history file" << historyFile.fileName(); return; } @@ -340,7 +340,7 @@ void HistoryManager::save() if (!open) { - qWarning() << "Unable to open history file for saving" + kWarning() << "Unable to open history file for saving" << (saveAll ? tempFile.fileName() : historyFile.fileName()); return; } @@ -359,9 +359,9 @@ void HistoryManager::save() if (saveAll) { if (historyFile.exists() && !historyFile.remove()) - qWarning() << "History: error removing old history." << historyFile.errorString(); + kWarning() << "History: error removing old history." << historyFile.errorString(); if (!tempFile.rename(historyFile.fileName())) - qWarning() << "History: error moving new history over old." << tempFile.errorString() << historyFile.fileName(); + kWarning() << "History: error moving new history over old." << tempFile.errorString() << historyFile.fileName(); } m_lastSavedUrl = m_history.value(0).url; } diff --git a/src/webview.cpp b/src/webview.cpp index f836b5ea..edae86eb 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -237,7 +237,7 @@ void WebView::loadFinished() { if (m_progress != 100) { - qWarning() << "Recieved finished signal while progress is still:" << progress() + kWarning() << "Recieved finished signal while progress is still:" << progress() << "Url:" << url(); } m_progress = 0; -- cgit v1.2.1 From 728c3cd887662922ee2db802bd91c9a3a1d032ac Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 18 Dec 2008 01:28:37 +0100 Subject: Adjusted download directory requester --- src/settings.cpp | 8 +++++--- src/settings.ui | 33 ++++++++++++++++++++++----------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index 355799bd..895a22d9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -33,6 +33,7 @@ // KDE Includes #include #include +#include // Qt Includes #include @@ -49,6 +50,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) setWindowTitle( i18n("Setting rekonq..") ); setButtons( KDialog::Ok | KDialog::Close | KDialog::Apply ); + kurlrequester->setMode( KFile::Directory ); setModal(true); connect(this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) ); @@ -79,7 +81,7 @@ void SettingsDialog::loadDefaults() m_fixedFont = QFont(fixedFontFamily, fixedFontSize); fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); - downloadsLocation->setText(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); + kurlrequester->setUrl( KUrl( "~" ) ); // QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) ); enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); @@ -109,7 +111,7 @@ void SettingsDialog::loadFromSettings() expireHistory->setCurrentIndex(idx); QString downloadDirectory = group1.readEntry( QString("downloadDirectory") , QString() ); - downloadsLocation->setText(downloadDirectory); + kurlrequester->setUrl( KUrl(downloadDirectory) ); openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), openLinksIn->currentIndex() ) ); @@ -185,7 +187,7 @@ void SettingsDialog::saveToSettings() group1.writeEntry(QString("home"), homeLineEdit->text() ); group1.writeEntry(QString("openLinksIn"), openLinksIn->currentIndex() ); - group1.writeEntry(QString("downloadDirectory"), downloadsLocation->text() ); + group1.writeEntry(QString("downloadDirectory"), kurlrequester->url().path() ); int historyExpire = expireHistory->currentIndex(); int idx = -1; diff --git a/src/settings.ui b/src/settings.ui index 38c5ff13..31945906 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -33,17 +33,17 @@
- + - + Set to current page - + Qt::Horizontal @@ -66,7 +66,7 @@ - + @@ -110,9 +110,6 @@ - - - @@ -123,7 +120,7 @@ - + @@ -137,7 +134,7 @@ - + Qt::Vertical @@ -150,6 +147,9 @@ + + + @@ -476,8 +476,7 @@ - - + @@ -501,6 +500,18 @@ + + + KLineEdit + QLineEdit +
klineedit.h
+
+ + KUrlRequester + QFrame +
kurlrequester.h
+
+
-- cgit v1.2.1 From 0dc1272340d4deda7f9b07c5278fac9e04383b18 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 18 Dec 2008 02:51:24 +0100 Subject: Lots of improvements in save/restore state functions. - saving toolbar lock - removing unuseful save/restore tabWidget functions - saving navigation toolbar settings --- src/browsermainwindow.cpp | 80 ++++++++++++++++++++++++++++------------------- src/browsermainwindow.h | 9 +++--- src/main.cpp | 9 ++++-- src/tabwidget.cpp | 4 +-- src/tabwidget.h | 4 +-- 5 files changed, 63 insertions(+), 43 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 8a936774..32dd13a3 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -126,15 +126,18 @@ void BrowserMainWindow::save() KConfig config("rekonqrc"); KConfigGroup group1 = config.group("BrowserMainWindow"); - QByteArray data = saveState(false); + QByteArray data = saveState(); group1.writeEntry( QString("defaultState"), data ); + + KConfigGroup group2 = config.group("navigation toobar"); + m_navigationBar->saveSettings( group2 ); } static const qint32 BrowserMainWindowMagic = 0xba; -QByteArray BrowserMainWindow::saveState(bool withTabs) const +QByteArray BrowserMainWindow::saveState() const { int version = 2; QByteArray data; @@ -144,25 +147,28 @@ QByteArray BrowserMainWindow::saveState(bool withTabs) const stream << qint32(version); stream << size(); -// stream << !( statusBar()->isHidden() ); FIXME - if (withTabs) -// stream << tabWidget()->saveState(); - ; - else + + stream << KToolBar::toolBarsLocked(); + bool b = true; // statusBar()->isVisible() ; FIXME + stream << b; +// if (withTabs) +// // stream << tabWidget()->saveState(); +// ; +// else stream << QByteArray(); return data; } -bool BrowserMainWindow::restoreState(const QByteArray &state) +void BrowserMainWindow::restoreState(const QByteArray &state) { int version = 2; QByteArray sd = state; QDataStream stream(&sd, QIODevice::ReadOnly); if ( stream.atEnd() ) { - return false; + return; } qint32 marker; @@ -171,26 +177,29 @@ bool BrowserMainWindow::restoreState(const QByteArray &state) stream >> v; if (marker != BrowserMainWindowMagic || v != version) { - return false; + return; } QSize size; - bool showStatusbar = true; + bool showStatusbar; + bool toolbarsLocked; QByteArray tabState; stream >> size; -// stream >> showStatusbar; FIXME see 30 lines over.. - stream >> tabState; + stream >> toolbarsLocked; + stream >> showStatusbar; +// stream >> tabState; resize(size); statusBar()->setVisible(showStatusbar); updateStatusbarActionText(showStatusbar); - if ( !tabWidget()->restoreState(tabState) ) - { - return false; - } - return true; + KToolBar::setToolBarsLocked ( toolbarsLocked ); +// if ( !tabWidget()->restoreState(tabState) ) +// { +// return false; +// } + return; } @@ -302,23 +311,19 @@ void BrowserMainWindow::setupMenu() m_historyBack = new KAction( i18n("Back"), this); m_historyBack->setShortcut( KShortcut( QKeySequence::Back ) ); - m_tabWidget->addWebAction(m_historyBack, QWebPage::Back); + m_tabWidget->addWebAction( m_historyBack, QWebPage::Back ); m_historyBack->setIconVisibleInMenu(false); m_historyForward = new KAction( i18n("Forward"), this); m_historyForward->setShortcut( KShortcut( QKeySequence::Forward ) ); - m_tabWidget->addWebAction(m_historyForward, QWebPage::Forward); + m_tabWidget->addWebAction( m_historyForward, QWebPage::Forward ); m_historyForward->setIconVisibleInMenu(false); - m_restoreLastSession = new KAction( i18n("Restore Last Session"), this); - connect(m_restoreLastSession, SIGNAL(triggered()), BrowserApplication::instance(), SLOT(restoreLastSession())); - m_restoreLastSession->setEnabled(BrowserApplication::instance()->canRestoreSession()); - - historyActions.append(m_historyBack); - historyActions.append(m_historyForward); + historyActions.append( m_historyBack ); + historyActions.append( m_historyForward ); historyActions.append( KStandardAction::home(this, SLOT( slotHome() ) , this ) ); - historyActions.append(m_tabWidget->recentlyClosedTabsAction()); - historyActions.append(m_restoreLastSession); + historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); + historyMenu->setInitialActions(historyActions); @@ -380,10 +385,16 @@ void BrowserMainWindow::setupToolBar() // UI settings setContextMenuPolicy( Qt::PreventContextMenu ); - m_navigationBar->setIconDimensions(22); - KToolBar::setToolBarsEditable( false ); - KToolBar::setToolBarsLocked( true ); +// m_navigationBar->setIconDimensions(22); +// m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly ); +// KToolBar::setToolBarsEditable( false ); +// KToolBar::setToolBarsLocked( true ); + + KConfig config("rekonqrc"); + KConfigGroup group = config.group("navigation toobar"); + m_navigationBar->applySettings( group ); + } @@ -504,9 +515,12 @@ void BrowserMainWindow::slotUpdateStatusbar(const QString &string) void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) { - if (title.isEmpty()) { + if (title.isEmpty()) + { setWindowTitle("rekonq"); - } else { + } + else + { setWindowTitle(title + " - rekonq"); } } diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h index d50abcc4..3bd80168 100644 --- a/src/browsermainwindow.h +++ b/src/browsermainwindow.h @@ -41,9 +41,8 @@ class QWebFrame; class TabWidget; class WebView; -/*! +/** The MainWindow of the Browser Application. - Handles the tab widget and all the actions */ class BrowserMainWindow : public KMainWindow @@ -57,8 +56,10 @@ public: static KUrl guessUrlFromString(const QString &url); TabWidget *tabWidget() const; WebView *currentTab() const; - QByteArray saveState(bool withTabs = true) const; - bool restoreState(const QByteArray &state); + + + QByteArray saveState() const; + void restoreState(const QByteArray &state); public slots: void loadPage(const QString &url); diff --git a/src/main.cpp b/src/main.cpp index e2f74b4d..7963405d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -41,13 +41,18 @@ int main(int argc, char **argv) "adjam7@gmail.com" // bug report mail ); - aboutData.addAuthor(ki18n("Andrea Diamantini"), ki18n("rekonq author"), "adjam7@gmail.com"); + aboutData.addAuthor( + ki18n("Andrea Diamantini"), + ki18n("rekonq author"), + "adjam7@gmail.com" + ); + aboutData.setProgramIconName("applications-internet"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineOptions options; - options.add("+URL", ki18n("Location to open")); + options.add( "+URL" , ki18n("Location to open") ); KCmdLineArgs::addCmdLineOptions( options ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 24aacfff..7d0fb788 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -774,7 +774,7 @@ void TabWidget::previousTab() setCurrentIndex(next); } - +/* static const qint32 TabWidgetMagic = 0xaa; @@ -835,7 +835,7 @@ bool TabWidget::restoreState(const QByteArray &state) setCurrentIndex(currentTab); return true; -} +}*/ // ---------------------------------------------------------------------------------------------------------------------------- diff --git a/src/tabwidget.h b/src/tabwidget.h index 1a46371c..d99ff156 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -168,8 +168,8 @@ public: QLineEdit *lineEdit(int index) const; int webViewIndex(WebView *webView) const; - QByteArray saveState() const; - bool restoreState(const QByteArray &state); +// QByteArray saveState() const; +// bool restoreState(const QByteArray &state); protected: void mouseDoubleClickEvent(QMouseEvent *event); -- cgit v1.2.1 From 86d8f3f8e651d73adb764e6f8ea35ae426454e9e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 19 Dec 2008 12:07:54 +0100 Subject: Properly setting toolbars! Yeah! --- src/browsermainwindow.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 32dd13a3..a37037f7 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -356,7 +356,7 @@ void BrowserMainWindow::setupMenu() void BrowserMainWindow::setupToolBar() { - m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, false); + m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, true); m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); @@ -386,15 +386,16 @@ void BrowserMainWindow::setupToolBar() // UI settings setContextMenuPolicy( Qt::PreventContextMenu ); -// m_navigationBar->setIconDimensions(22); -// m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly ); -// KToolBar::setToolBarsEditable( false ); -// KToolBar::setToolBarsLocked( true ); + // setting initial style (if user hasn't decided something else) + m_navigationBar->setIconDimensions(22); + m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly ); KConfig config("rekonqrc"); KConfigGroup group = config.group("navigation toobar"); - m_navigationBar->applySettings( group ); - + if ( group.exists() ) + { + m_navigationBar->applySettings( group ); + } } -- cgit v1.2.1 From 16ab5690568b926f226c3144cef207d9ef59fa17 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 20 Dec 2008 23:38:00 +0100 Subject: Added .desktop file --- TODO | 9 ++++++--- data/CMakeLists.txt | 5 +++++ data/rekonq.desktop | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 data/rekonq.desktop diff --git a/TODO b/TODO index a357e0c7..d05fa403 100644 --- a/TODO +++ b/TODO @@ -27,8 +27,11 @@ NEXT.. - contextMenu in searchbar to set different search engines - save toolbars settings - NEW save/load setting functions in KMainWIndow -- improve CMakeLists.txt 4.4 required, 4.5 better.. ++ improve CMakeLists.txt 4.4 required, 4.5 better.. - browse code to search TODO and FIXME -- qDebug --> kWarning() / kDebug()! -- dbus support ++ qDebug --> kWarning() / kDebug()! +- dbus support + - kget support + - kwallet support + - kwrite support ( optional, to view HTML code ) diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 2882b681..41c9995f 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -3,3 +3,8 @@ INSTALL( FILES loading.gif DESTINATION ${DATA_INSTALL_DIR}/rekonq/pics ) + +INSTALL( FILES + rekonq.desktop + DESTINATION ${XDG_APPS_INSTALL_DIR} +) diff --git a/data/rekonq.desktop b/data/rekonq.desktop new file mode 100644 index 00000000..4d22c75f --- /dev/null +++ b/data/rekonq.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=rekonq +GenericName=Webkit KDE Browser +Icon=rekonq +Type=Application +Exec=rekonq %u +X-DocPath=rekonq/index.html +Categories=Qt;KDE;Network; \ No newline at end of file -- cgit v1.2.1 From 85088c590ef99f9487abf2768f8084653cd4ab16 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 21 Dec 2008 00:07:53 +0100 Subject: - Added kWarning for fixed minimun size - updated TODO - upgraded .desktop file --- TODO | 8 ++------ data/rekonq.desktop | 2 +- src/searchbar.cpp | 2 ++ 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index d05fa403..09ca6d5d 100644 --- a/TODO +++ b/TODO @@ -11,21 +11,17 @@ Road to 0.0.1 (first release) NEXT.. -- Fixing QByteArray save/load state!! ++ Fixing QByteArray save/load state!! - system SELECT ALL - better FULL SCREEN - simplify history -- KDE download = Kjob && Kget -- configure dialog (A-LA amarok, konqueror) -- dbus support (?!) -- KWallet support - Kpart ?? +------------------------ - contextMenu in searchbar to set different search engines -- save toolbars settings ++ save toolbars settings - NEW save/load setting functions in KMainWIndow + improve CMakeLists.txt 4.4 required, 4.5 better.. - browse code to search TODO and FIXME diff --git a/data/rekonq.desktop b/data/rekonq.desktop index 4d22c75f..126cba2a 100644 --- a/data/rekonq.desktop +++ b/data/rekonq.desktop @@ -5,4 +5,4 @@ Icon=rekonq Type=Application Exec=rekonq %u X-DocPath=rekonq/index.html -Categories=Qt;KDE;Network; \ No newline at end of file +Categories=Qt;KDE;Network; diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 0cf8e801..8b21daf5 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -29,6 +29,8 @@ SearchBar::SearchBar(QWidget *parent) : KLineEdit(parent) { setMinimumWidth(180); + kWarning() << "setting fixed minimum width.." ; + setFocusPolicy( Qt::WheelFocus ); setMouseTracking( true ); setAcceptDrops(true); -- cgit v1.2.1 From 2daca1034d63d71e9c6a097816fe6aa7ba47db35 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 21 Dec 2008 00:54:58 +0100 Subject: little updates.. --- TODO | 22 +++++++++++----------- src/findbar.cpp | 5 ++--- src/searchbar.cpp | 1 + src/urlbar.h | 3 +-- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index 09ca6d5d..33d63af4 100644 --- a/TODO +++ b/TODO @@ -11,23 +11,23 @@ Road to 0.0.1 (first release) NEXT.. -+ Fixing QByteArray save/load state!! - system SELECT ALL - better FULL SCREEN - simplify history - -- Kpart ?? - -+------------------------ - +- KDE autosave +- kMainWindow save/read settings +- color progress - contextMenu in searchbar to set different search engines -+ save toolbars settings -- NEW save/load setting functions in KMainWIndow -+ improve CMakeLists.txt 4.4 required, 4.5 better.. -- browse code to search TODO and FIXME -+ qDebug --> kWarning() / kDebug()! + +- QWebPluginFactory subclass to load KParts into QtWebKit. - dbus support - kget support - kwallet support - kwrite support ( optional, to view HTML code ) + +- Kpart ?? + ++------------------------ + + diff --git a/src/findbar.cpp b/src/findbar.cpp index b45dc8fa..73f6c784 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -41,6 +41,8 @@ FindBar::FindBar(KMainWindow *parent) addWidget( label ); m_lineEdit = new KLineEdit(); + m_lineEdit->setMaximumWidth( 200 ); + connect( m_lineEdit, SIGNAL( returnPressed() ), parent, SLOT( slotFindNext() ) ); connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), parent, SLOT( slotFindNext() ) ); addWidget( m_lineEdit ); @@ -48,9 +50,6 @@ FindBar::FindBar(KMainWindow *parent) addAction( KStandardAction::findNext(parent, SLOT( slotFindNext() ) , this ) ); addAction( KStandardAction::findPrev(parent, SLOT( slotFindPrevious() ) , this ) ); - QLabel *spaceLabel = new QLabel(" "); // FIXME - addWidget( spaceLabel ); - // we start off hidden hide(); } diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 8b21daf5..977703d3 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -24,6 +24,7 @@ #include "browserapplication.h" #include "browsermainwindow.h" +#include SearchBar::SearchBar(QWidget *parent) : KLineEdit(parent) diff --git a/src/urlbar.h b/src/urlbar.h index 99199d9c..c77f3b77 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -46,8 +46,7 @@ private slots: void webViewIconChanged(); protected: -// void paintEvent( QPaintEvent * ); - +// void paintEvent( QPaintEvent * ); private: QLinearGradient generateGradient(const QColor &color) const; -- cgit v1.2.1 From cb8ae84a4e2b0c9fa0f1ea8b49401a64f8779fbc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 21 Dec 2008 23:28:11 +0100 Subject: Polishing code a bit.. --- src/browsermainwindow.cpp | 11 +----- src/tabwidget.cpp | 85 +++++++++-------------------------------------- src/tabwidget.h | 3 -- 3 files changed, 16 insertions(+), 83 deletions(-) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index a37037f7..9fa6b4f6 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -151,11 +151,7 @@ QByteArray BrowserMainWindow::saveState() const stream << KToolBar::toolBarsLocked(); bool b = true; // statusBar()->isVisible() ; FIXME stream << b; -// if (withTabs) -// // stream << tabWidget()->saveState(); -// ; -// else - stream << QByteArray(); + stream << QByteArray(); return data; } @@ -188,17 +184,12 @@ void BrowserMainWindow::restoreState(const QByteArray &state) stream >> size; stream >> toolbarsLocked; stream >> showStatusbar; -// stream >> tabState; resize(size); statusBar()->setVisible(showStatusbar); updateStatusbarActionText(showStatusbar); KToolBar::setToolBarsLocked ( toolbarsLocked ); -// if ( !tabWidget()->restoreState(tabState) ) -// { -// return false; -// } return; } diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 7d0fb788..06a14ff3 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -774,69 +774,6 @@ void TabWidget::previousTab() setCurrentIndex(next); } -/* -static const qint32 TabWidgetMagic = 0xaa; - - -QByteArray TabWidget::saveState() const -{ - int version = 1; - QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); - - stream << qint32(TabWidgetMagic); - stream << qint32(version); - - QStringList tabs; - for (int i = 0; i < count(); ++i) - { - if (WebView *tab = qobject_cast(widget(i))) - { - tabs.append(tab->url().prettyUrl()); - } - else - { - tabs.append(QString::null); - } - } - stream << tabs; - stream << currentIndex(); - return data; -} - - -bool TabWidget::restoreState(const QByteArray &state) -{ - int version = 1; - QByteArray sd = state; - QDataStream stream(&sd, QIODevice::ReadOnly); - if (stream.atEnd()) - return false; - - qint32 marker; - qint32 v; - stream >> marker; - stream >> v; - if (marker != TabWidgetMagic || v != version) - return false; - - QStringList openTabs; - stream >> openTabs; - - for (int i = 0; i < openTabs.count(); ++i) - { - if (i != 0) - newTab(); - loadPage(openTabs.at(i)); - } - - int currentTab; - stream >> currentTab; - setCurrentIndex(currentTab); - - return true; -}*/ - // ---------------------------------------------------------------------------------------------------------------------------- @@ -847,10 +784,13 @@ WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, Q , m_root(root) , m_webAction(webAction) { - if (!m_root) + if ( !m_root ) + { return; - connect(m_root, SIGNAL(triggered()), this, SLOT(rootTriggered())); - connect(root, SIGNAL(destroyed(QObject *)), this, SLOT(rootDestroyed())); + } + connect(m_root, SIGNAL( triggered() ), this, SLOT( rootTriggered() ) ); + connect(root, SIGNAL( destroyed(QObject *) ), this, SLOT( rootDestroyed() ) ); + root->setEnabled(false); } @@ -869,9 +809,11 @@ void WebActionMapper::currentDestroyed() void WebActionMapper::addChild(KAction *action) { - if (!action) + if ( !action ) + { return; - connect(action, SIGNAL(changed()), this, SLOT(childChanged())); + } + connect(action, SIGNAL( changed() ), this, SLOT( childChanged() ) ); } QWebPage::WebAction WebActionMapper::webAction() const @@ -913,8 +855,11 @@ void WebActionMapper::updateCurrent(QWebPage *currentParent) m_currentParent = currentParent; if (!m_root) + { return; - if (!m_currentParent) { + } + if (!m_currentParent) + { m_root->setEnabled(false); m_root->setChecked(false); return; @@ -922,5 +867,5 @@ void WebActionMapper::updateCurrent(QWebPage *currentParent) KAction *source = new KAction( m_currentParent->action(m_webAction) ); m_root->setChecked(source->isChecked()); m_root->setEnabled(source->isEnabled()); - connect(m_currentParent, SIGNAL(destroyed(QObject *)), this, SLOT(currentDestroyed())); + connect(m_currentParent, SIGNAL( destroyed(QObject *) ), this, SLOT( currentDestroyed() ) ); } diff --git a/src/tabwidget.h b/src/tabwidget.h index d99ff156..4edba9b9 100644 --- a/src/tabwidget.h +++ b/src/tabwidget.h @@ -168,9 +168,6 @@ public: QLineEdit *lineEdit(int index) const; int webViewIndex(WebView *webView) const; -// QByteArray saveState() const; -// bool restoreState(const QByteArray &state); - protected: void mouseDoubleClickEvent(QMouseEvent *event); void contextMenuEvent(QContextMenuEvent *event); -- cgit v1.2.1 From 44bb7b573b225d9021c1110203f4650dd79c7297 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 22 Dec 2008 01:22:23 +0100 Subject: New Config Dialog. Yeah! --- src/CMakeLists.txt | 5 +- src/settings.cpp | 172 ++++++++++++++++++++++++++++++--------------- src/settings.h | 10 ++- src/settings_appearance.ui | 98 ++++++++++++++++++++++++++ src/settings_general.ui | 159 +++++++++++++++++++++++++++++++++++++++++ src/settings_privacy.ui | 130 ++++++++++++++++++++++++++++++++++ src/settings_proxy.ui | 148 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 663 insertions(+), 59 deletions(-) create mode 100644 src/settings_appearance.ui create mode 100644 src/settings_general.ui create mode 100644 src/settings_privacy.ui create mode 100644 src/settings_proxy.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e2a3866..d53a7add 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,7 +28,10 @@ KDE4_ADD_UI_FILES( rekonq_SRCS history.ui passworddialog.ui proxy.ui - settings.ui + settings_general.ui + settings_appearance.ui + settings_privacy.ui + settings_proxy.ui ) # include(${QT_USE_FILE}) diff --git a/src/settings.cpp b/src/settings.cpp index 895a22d9..f8fd818f 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -30,8 +30,16 @@ #include "networkaccessmanager.h" #include "webview.h" +//Ui Includes +#include "ui_settings_general.h" +#include "ui_settings_appearance.h" +#include "ui_settings_privacy.h" +#include "ui_settings_proxy.h" + // KDE Includes #include +#include +#include #include #include @@ -39,52 +47,103 @@ #include #include -SettingsDialog::SettingsDialog(QWidget *parent) - : KDialog(parent) + +class Private { - QWidget *widget = new QWidget; +private: + Ui::general generalUi; + Ui::appearance appearanceUi; + Ui::privacy privacyUi; + Ui::proxy proxyUi; + + Private(SettingsDialog *parent); + +friend class SettingsDialog; +}; + + +Private::Private(SettingsDialog *parent) +{ + QWidget *widget; + KPageWidgetItem *pageItem; + + widget = new QWidget; + generalUi.setupUi( widget ); + widget->layout()->setMargin(0); + pageItem = parent->addPage( widget , i18n("General") ); + pageItem->setIcon( KIcon("rekonq") ); + generalUi.kurlrequester->setMode( KFile::Directory ); + + widget = new QWidget; + appearanceUi.setupUi( widget ); + widget->layout()->setMargin(0); + pageItem = parent->addPage( widget , i18n("Appearance") ); + pageItem->setIcon( KIcon("kfontview") ); + + widget = new QWidget; + privacyUi.setupUi( widget ); + widget->layout()->setMargin(0); + pageItem = parent->addPage( widget , i18n("Privacy") ); + pageItem->setIcon( KIcon("preferences-desktop-personal") ); + + widget = new QWidget; + proxyUi.setupUi( widget ); + widget->layout()->setMargin(0); + pageItem = parent->addPage( widget , i18n("Proxy") ); + pageItem->setIcon( KIcon("preferences-system-network") ); +} - setupUi(widget); +// ----------------------------------------------------------------------------------------------------- - setMainWidget(widget); +SettingsDialog::SettingsDialog(QWidget *parent) + : KConfigDialog(parent, "Settings", new KConfigSkeleton("rekonqrc") ) + , d(new Private(this) ) +{ + setFaceType(KPageDialog::List); + setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); + showButtonSeparator(true); setWindowTitle( i18n("Setting rekonq..") ); - setButtons( KDialog::Ok | KDialog::Close | KDialog::Apply ); - kurlrequester->setMode( KFile::Directory ); setModal(true); connect(this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) ); connect(this, SIGNAL( closeClicked() ), this, SLOT( close() ) ); connect(this, SIGNAL( applyClicked() ), this, SLOT( slotApply() ) ); - connect(exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); - connect(setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); - connect(cookiesButton, SIGNAL(clicked()), this, SLOT( showCookies() ) ); - connect(standardFontButton, SIGNAL(clicked()), this, SLOT( chooseFont() ) ); - connect(fixedFontButton, SIGNAL(clicked()), this, SLOT( chooseFixedFont() ) ); + connect( d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); + connect( d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); + connect( d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT( showCookies() ) ); + connect( d->appearanceUi.standardFontButton, SIGNAL(clicked()), this, SLOT( chooseFont() ) ); + connect( d->appearanceUi.fixedFontButton, SIGNAL(clicked()), this, SLOT( chooseFixedFont() ) ); loadDefaults(); loadFromSettings(); } +SettingsDialog::~SettingsDialog() +{ + delete d; +} + + void SettingsDialog::loadDefaults() { QWebSettings *defaultSettings = QWebSettings::globalSettings(); QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); m_standardFont = QFont(standardFontFamily, standardFontSize); - standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() )); + d->appearanceUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() )); QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); m_fixedFont = QFont(fixedFontFamily, fixedFontSize); - fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); + d->appearanceUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); - kurlrequester->setUrl( KUrl( "~" ) ); // QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) ); + d->generalUi.kurlrequester->setUrl( KUrl( "~" ) ); // QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) ); - enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); - enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); + d->privacyUi.enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); + d->privacyUi.enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); } @@ -94,7 +153,7 @@ void SettingsDialog::loadFromSettings() KConfigGroup group1 = config.group("Global Settings"); QString defaultHome = QString("http://www.kde.org"); - homeLineEdit->setText( group1.readEntry(QString("home"), defaultHome) ); + d->generalUi.homeLineEdit->setText( group1.readEntry(QString("home"), defaultHome) ); int historyExpire = group1.readEntry( QString("historyExpire"), QString().toInt() ); int idx = 0; @@ -108,12 +167,12 @@ void SettingsDialog::loadFromSettings() case -1: idx = 5; break; default: idx = 5; } - expireHistory->setCurrentIndex(idx); + d->generalUi.expireHistory->setCurrentIndex(idx); QString downloadDirectory = group1.readEntry( QString("downloadDirectory") , QString() ); - kurlrequester->setUrl( KUrl(downloadDirectory) ); + d->generalUi.kurlrequester->setUrl( KUrl(downloadDirectory) ); - openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), openLinksIn->currentIndex() ) ); + d->generalUi.openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ) ); // Appearance @@ -122,15 +181,15 @@ void SettingsDialog::loadFromSettings() m_fixedFont = group2.readEntry( QString("fixedFont"), m_fixedFont ); m_standardFont = group2.readEntry( QString("standardFont"), m_standardFont ); - standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); - fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); - - enableJavascript->setChecked( group2.readEntry( QString("enableJavascript"), enableJavascript->isChecked() ) ); - enablePlugins->setChecked( group2.readEntry( QString("enablePlugins"), enablePlugins->isChecked() ) ); + d->appearanceUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); + d->appearanceUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); // Privacy KConfigGroup group3 = config.group("Privacy Settings"); + d->privacyUi.enableJavascript->setChecked( group3.readEntry( QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ) ); + d->privacyUi.enablePlugins->setChecked( group3.readEntry( QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ) ); + CookieJar *jar = BrowserApplication::cookieJar(); QString value = group3.readEntry( QString("acceptCookies"), QString("AcceptOnlyFromSitesNavigatedTo") ) ; QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); @@ -140,13 +199,13 @@ void SettingsDialog::loadFromSettings() switch(acceptCookies) { case CookieJar::AcceptAlways: - acceptCombo->setCurrentIndex(0); + d->privacyUi.acceptCombo->setCurrentIndex(0); break; case CookieJar::AcceptNever: - acceptCombo->setCurrentIndex(1); + d->privacyUi.acceptCombo->setCurrentIndex(1); break; case CookieJar::AcceptOnlyFromSitesNavigatedTo: - acceptCombo->setCurrentIndex(2); + d->privacyUi.acceptCombo->setCurrentIndex(2); break; } @@ -155,27 +214,28 @@ void SettingsDialog::loadFromSettings() CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? CookieJar::KeepUntilExpire : static_cast(keepPolicyEnum.keyToValue( value.toLocal8Bit() ) ); - switch(keepCookies) { + switch(keepCookies) + { case CookieJar::KeepUntilExpire: - keepUntilCombo->setCurrentIndex(0); + d->privacyUi.keepUntilCombo->setCurrentIndex(0); break; case CookieJar::KeepUntilExit: - keepUntilCombo->setCurrentIndex(1); + d->privacyUi.keepUntilCombo->setCurrentIndex(1); break; case CookieJar::KeepUntilTimeLimit: - keepUntilCombo->setCurrentIndex(2); + d->privacyUi.keepUntilCombo->setCurrentIndex(2); break; } // Proxy KConfigGroup group4 = config.group("Proxy Settings"); - proxySupport->setChecked( group4.readEntry( QString("enabled"), false ) ); - proxyType->setCurrentIndex( group4.readEntry( QString("type"), 0) ); - proxyHostName->setText( group4.readEntry( QString("hostName"), QString() ) ); - proxyPort->setValue( group4.readEntry( QString("port"), QString().toInt() ) ); - proxyUserName->setText( group4.readEntry( QString("userName") , QString() ) ); - proxyPassword->setText( group4.readEntry( QString("password") , QString() ) ); + d->proxyUi.proxySupport->setChecked( group4.readEntry( QString("enabled"), false ) ); + d->proxyUi.proxyType->setCurrentIndex( group4.readEntry( QString("type"), 0) ); + d->proxyUi.proxyHostName->setText( group4.readEntry( QString("hostName"), QString() ) ); + d->proxyUi.proxyPort->setValue( group4.readEntry( QString("port"), QString().toInt() ) ); + d->proxyUi.proxyUserName->setText( group4.readEntry( QString("userName") , QString() ) ); + d->proxyUi.proxyPassword->setText( group4.readEntry( QString("password") , QString() ) ); } @@ -185,11 +245,11 @@ void SettingsDialog::saveToSettings() KConfig config("rekonqrc"); KConfigGroup group1 = config.group("Global Settings"); - group1.writeEntry(QString("home"), homeLineEdit->text() ); - group1.writeEntry(QString("openLinksIn"), openLinksIn->currentIndex() ); - group1.writeEntry(QString("downloadDirectory"), kurlrequester->url().path() ); + group1.writeEntry(QString("home"), d->generalUi.homeLineEdit->text() ); + group1.writeEntry(QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ); + group1.writeEntry(QString("downloadDirectory"), d->generalUi.kurlrequester->url().path() ); - int historyExpire = expireHistory->currentIndex(); + int historyExpire = d->generalUi.expireHistory->currentIndex(); int idx = -1; switch (historyExpire) { @@ -207,11 +267,11 @@ void SettingsDialog::saveToSettings() group2.writeEntry(QString("standardFont"), m_standardFont); KConfigGroup group3 = config.group("Privacy Settings"); - group3.writeEntry(QString("enableJavascript"), enableJavascript->isChecked() ); - group3.writeEntry(QString("enablePlugins"), enablePlugins->isChecked() ); + group3.writeEntry(QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ); + group3.writeEntry(QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ); CookieJar::KeepPolicy keepCookies; - switch(acceptCombo->currentIndex()) + switch( d->privacyUi.acceptCombo->currentIndex() ) { default: case 0: @@ -229,7 +289,7 @@ void SettingsDialog::saveToSettings() group3.writeEntry(QString("acceptCookies"), QString(acceptPolicyEnum.valueToKey(keepCookies) ) ); CookieJar::KeepPolicy keepPolicy; - switch(keepUntilCombo->currentIndex()) + switch( d->privacyUi.keepUntilCombo->currentIndex() ) { default: case 0: @@ -248,12 +308,12 @@ void SettingsDialog::saveToSettings() KConfigGroup group4 = config.group("Proxy Settings"); - group4.writeEntry(QString("enabled"), proxySupport->isChecked() ); - group4.writeEntry(QString("type"), proxyType->currentIndex() ); - group4.writeEntry(QString("hostName"), proxyHostName->text() ); - group4.writeEntry(QString("port"), proxyPort->text() ); - group4.writeEntry(QString("userName"), proxyUserName->text() ); - group4.writeEntry(QString("password"), proxyPassword->text() ); + group4.writeEntry(QString("enabled"), d->proxyUi.proxySupport->isChecked() ); + group4.writeEntry(QString("type"), d->proxyUi.proxyType->currentIndex() ); + group4.writeEntry(QString("hostName"), d->proxyUi.proxyHostName->text() ); + group4.writeEntry(QString("port"), d->proxyUi.proxyPort->text() ); + group4.writeEntry(QString("userName"), d->proxyUi.proxyUserName->text() ); + group4.writeEntry(QString("password"), d->proxyUi.proxyPassword->text() ); config.sync(); @@ -286,7 +346,7 @@ void SettingsDialog::chooseFont() if ( result == KFontDialog::Accepted ) { m_standardFont = myFont; - standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); + d->appearanceUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); } } @@ -299,7 +359,7 @@ void SettingsDialog::chooseFixedFont() if ( result == KFontDialog::Accepted ) { m_fixedFont = myFont; - fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); + d->appearanceUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); } } @@ -310,7 +370,7 @@ void SettingsDialog::setHomeToCurrentPage() WebView *webView = mw->currentTab(); if (webView) { - homeLineEdit->setText( webView->url().prettyUrl() ); + d->generalUi.homeLineEdit->setText( webView->url().prettyUrl() ); } } diff --git a/src/settings.h b/src/settings.h index 39845c63..e76d6da6 100644 --- a/src/settings.h +++ b/src/settings.h @@ -25,18 +25,24 @@ #include "ui_settings.h" // KDE Includes -#include +#include // Qt Includes #include -class SettingsDialog : public KDialog, private Ui::Settings +class Private; + +class SettingsDialog : public KConfigDialog { Q_OBJECT public: SettingsDialog(QWidget *parent = 0); + ~SettingsDialog(); +private: + Private* const d; + private slots: void loadDefaults(); void loadFromSettings(); diff --git a/src/settings_appearance.ui b/src/settings_appearance.ui new file mode 100644 index 00000000..ec82297c --- /dev/null +++ b/src/settings_appearance.ui @@ -0,0 +1,98 @@ + + appearance + + + + 0 + 0 + 445 + 92 + + + + Appearance + + + + + + + + Standard font: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Fixed-width font: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + Times 16 + + + Qt::AlignCenter + + + + + + + QFrame::StyledPanel + + + Courier 13 + + + Qt::AlignCenter + + + + + + + + + + + Select... + + + + + + + Select... + + + + + + + + + + diff --git a/src/settings_general.ui b/src/settings_general.ui new file mode 100644 index 00000000..4857488a --- /dev/null +++ b/src/settings_general.ui @@ -0,0 +1,159 @@ + + general + + + + 0 + 0 + 575 + 209 + + + + General + + + + + + Home: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Set to current page + + + + + + + Qt::Horizontal + + + + 233 + 25 + + + + + + + + Remove history items: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + After one day + + + + + After one week + + + + + After two weeks + + + + + After one month + + + + + After one year + + + + + Manually + + + + + + + + Save downloads to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Open links from applications: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + In a tab in the current window + + + + + In a new window + + + + + + + + Qt::Vertical + + + + 384 + 36 + + + + + + + + + KLineEdit + QLineEdit +
klineedit.h
+
+ + KUrlRequester + QFrame +
kurlrequester.h
+
+
+ + +
diff --git a/src/settings_privacy.ui b/src/settings_privacy.ui new file mode 100644 index 00000000..dfa61998 --- /dev/null +++ b/src/settings_privacy.ui @@ -0,0 +1,130 @@ + + privacy + + + + 0 + 0 + 461 + 212 + + + + Privacy + + + + + + Web Content + + + + + + Enable Plugins + + + true + + + + + + + Enable Javascript + + + true + + + + + + + + + + Cookies + + + + + + Accept Cookies: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Always + + + + + Never + + + + + Only from sites you navigate to + + + + + + + + Exceptions... + + + + + + + Keep until: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + They expire + + + + + I exit the application + + + + + At most 90 days + + + + + + + + Cookies... + + + + + + + + + + + diff --git a/src/settings_proxy.ui b/src/settings_proxy.ui new file mode 100644 index 00000000..c02dad27 --- /dev/null +++ b/src/settings_proxy.ui @@ -0,0 +1,148 @@ + + proxy + + + + 0 + 0 + 472 + 221 + + + + Proxy + + + + + + Enable proxy + + + true + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + Socks5 + + + + + Http + + + + + + + + Host: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Port: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 10000 + + + 1080 + + + + + + + Qt::Horizontal + + + + 293 + 20 + + + + + + + + User Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Password: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + Qt::Vertical + + + + 20 + 8 + + + + + + + + + + + + KLineEdit + QLineEdit +
klineedit.h
+
+
+ + +
-- cgit v1.2.1 From d427401e69464f35cb31b75f8873f2262ff8eb6c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 22 Dec 2008 01:25:18 +0100 Subject: window config title : rekonfig updated TODO --- TODO | 10 +- src/settings.cpp | 2 +- src/settings.ui | 517 ------------------------------------------------------- 3 files changed, 10 insertions(+), 519 deletions(-) delete mode 100644 src/settings.ui diff --git a/TODO b/TODO index 33d63af4..f68c7845 100644 --- a/TODO +++ b/TODO @@ -4,6 +4,13 @@ Road to 0.0.1 (first release) + bookmarks (share konqueror's) + some porting +ROAD to 0.0.2 (second release) ++ setting rekonq with KConfigDialog ("rekonfig") +- configure shortcuts +- better find toolbar +- fixed search bar width + ++ -------------------------------- 0.0.2 + QUrl --> KUrl + KDEize menubar (settings) @@ -18,6 +25,7 @@ NEXT.. - kMainWindow save/read settings - color progress - contextMenu in searchbar to set different search engines +- KDE proxy support - QWebPluginFactory subclass to load KParts into QtWebKit. @@ -28,6 +36,6 @@ NEXT.. - Kpart ?? -+------------------------ ++ ------------------------ diff --git a/src/settings.cpp b/src/settings.cpp index f8fd818f..f765e18c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -103,7 +103,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); showButtonSeparator(true); - setWindowTitle( i18n("Setting rekonq..") ); + setWindowTitle( i18n("rekonfig..") ); setModal(true); connect(this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) ); diff --git a/src/settings.ui b/src/settings.ui deleted file mode 100644 index 31945906..00000000 --- a/src/settings.ui +++ /dev/null @@ -1,517 +0,0 @@ - - Settings - - - - 0 - 0 - 570 - 248 - - - - Form - - - - - - 0 - - - - General - - - - - - Home: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Set to current page - - - - - - - Qt::Horizontal - - - - 280 - 18 - - - - - - - - Remove history items: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - After one day - - - - - After one week - - - - - After two weeks - - - - - After one month - - - - - After one year - - - - - Manually - - - - - - - - Save downloads to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Open links from applications: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - In a tab in the current window - - - - - In a new window - - - - - - - - Qt::Vertical - - - - 391 - 262 - - - - - - - - - - - - Appearance - - - - - - Standard font: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - Times 16 - - - Qt::AlignCenter - - - - - - - Select... - - - - - - - Fixed-width font: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - QFrame::StyledPanel - - - Courier 13 - - - Qt::AlignCenter - - - - - - - Select... - - - - - - - Qt::Vertical - - - - 20 - 93 - - - - - - - - - Privacy - - - - - - Web Content - - - - - - Enable Plugins - - - true - - - - - - - Enable Javascript - - - true - - - - - - - - - - Cookies - - - - - - Accept Cookies: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - Always - - - - - Never - - - - - Only from sites you navigate to - - - - - - - - Exceptions... - - - - - - - Keep until: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - They expire - - - - - I exit the application - - - - - At most 90 days - - - - - - - - Cookies... - - - - - - - - - - Qt::Vertical - - - - 371 - 177 - - - - - - - - - Proxy - - - - - - Enable proxy - - - true - - - - - - Type: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - Socks5 - - - - - Http - - - - - - - - Host: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Port: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 10000 - - - 1080 - - - - - - - Qt::Horizontal - - - - 293 - 20 - - - - - - - - User Name: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Password: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - Qt::Vertical - - - - 20 - 8 - - - - - - - - - - - - - - - - KLineEdit - QLineEdit -
klineedit.h
-
- - KUrlRequester - QFrame -
kurlrequester.h
-
-
- - -
-- cgit v1.2.1 From c8ecdd13ee1a66acc400b871ee4b4841537b1e82 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 22 Dec 2008 15:24:41 +0100 Subject: Comment --- src/browsermainwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp index 9fa6b4f6..cafb45bd 100644 --- a/src/browsermainwindow.cpp +++ b/src/browsermainwindow.cpp @@ -338,6 +338,7 @@ void BrowserMainWindow::setupMenu() // ------------------------------------------------------------- SETTINGS ------------------------------------------------------------------------------------------------------ KMenu *settingsMenu = (KMenu *) menuBar()->addMenu( i18n("&Settings") ); + settingsMenu->addAction( KStandardAction::keyBindings( this, SLOT( configureShortcuts() ), this ) ); //FIXME need new slot and actionCollection !! settingsMenu->addAction( KStandardAction::preferences(this, SLOT( slotPreferences() ) , this ) ); // ------------------------------------------------------------- HELP -------------------------------------------------------------------------------------------------- -- cgit v1.2.1 From 8438e0c0e3b60e83838425ecdbbe8afff5f67917 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 27 Dec 2008 10:14:37 +0100 Subject: Added SlackBuild --- rekonq.SlackBuild | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 rekonq.SlackBuild diff --git a/rekonq.SlackBuild b/rekonq.SlackBuild new file mode 100644 index 00000000..eefdc684 --- /dev/null +++ b/rekonq.SlackBuild @@ -0,0 +1,80 @@ +#!/bin/sh +# Slackware build script for $NAME +# Heavily based on the Slackware 12.2 SlackBuild +# Written by Andrea Diamantini - adjam7_AT_gmail_DOT_com + +NAME=rekonq +VERSION=0.0.2 +ARCH=${ARCH:-i486} +BUILD=1ad + +# working dirs +CWD=$(pwd) +TMP=$CWD/tmp +BUILDIR=$TMP/build +PKG=$TMP/package-$NAME + +KDEPREFIX=$(kde4-config --prefix) + +JOBS=${JOBS:-2} # Might not be wanted or needed in some cases + +if [ "$ARCH" = "i486" ]; then + SLKCFLAGS="-O2 -march=i486 -mtune=i686" +elif [ "$ARCH" = "i686" ]; then + SLKCFLAGS="-O3 -march=i686 -pipe -fomit-frame-pointer" +elif [ "$ARCH" = "athlon64" ]; then + SLKCFLAGS="-O2 -march=athlon64 -pipe" +elif [ "$ARCH" = "athlonxp" ]; then + SLKCFLAGS="-O3 -march=athlon-xp -pipe -fomit-frame-pointer" +elif [ "$ARCH" = "x86_64" ]; then + SLKCFLAGS="-O2" +fi + +rm -rf $TMP +mkdir -p $TMP $PKG $BUILDIR + +cd $BUILDIR + +# configure option for $NAME +cmake \ +-DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \ +-DCMAKE_INSTALL_PREFIX=$KDEPREFIX \ +-DCMAKE_BUILD_TYPE=release \ +$CWD + +# Compile the application and install it into the $PKG directory +nice make -j $JOBS || exit 1 +make install DESTDIR=$PKG || exit 1 + +# Strip binaries and libraries +( cd $PKG + find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null +) + + +# Copy program documentation into the package +# Also, include the SlackBuild script in the documentation directory +mkdir -p $PKG/usr/doc/$NAME-$VERSION +cp -a AUTHORS COPYING ChangeLog INSTALL NEWS README \ +$PKG/usr/doc/$NAME-$VERSION +cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild + +# Copy the slack-desc (and a custom doinst.sh if necessary) into ./install +mkdir -p $PKG/install +cat $CWD/slack-desc > $PKG/install/slack-desc +cat $CWD/doinst.sh > $PKG/install/doinst.sh + +# Make the package; +# If package symlinks need to be created during install *before* +# your custom contents of doinst.sh runs, then add the -p switch to +# the makepkg command below -- see makepkg(8) for details +cd $PKG +/sbin/makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz + +# remove unnecessary tmp dir.. +rm -rf $TMP + +# echo "done" +echo "done! Yuppy!!" + -- cgit v1.2.1 From 9f3c30305d1d1e850e4576e9257ef98fa57add75 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 27 Dec 2008 12:43:32 +0100 Subject: Ignoring .ctagsdb --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0beafa56..ba630bde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ qtdemobrowser releases +src/.ctagsdb -- cgit v1.2.1 From c7048563b95f8d27b20aac0a0e1fbc5c4584c514 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 27 Dec 2008 12:54:30 +0100 Subject: BrowserMainWindow --> MainWindow --- src/CMakeLists.txt | 2 +- src/bookmarks.cpp | 4 +- src/bookmarks.h | 4 +- src/browserapplication.cpp | 14 +- src/browserapplication.h | 10 +- src/browsermainwindow.cpp | 862 ------------------------------------------- src/browsermainwindow.h | 149 -------- src/mainwindow.cpp | 862 +++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 149 ++++++++ src/networkaccessmanager.cpp | 8 +- src/searchbar.cpp | 2 +- src/settings.cpp | 4 +- src/tabwidget.cpp | 2 +- src/tags | 494 ------------------------- src/urlbar.cpp | 2 +- src/webview.cpp | 10 +- src/webview.h | 4 +- 17 files changed, 1044 insertions(+), 1538 deletions(-) delete mode 100644 src/browsermainwindow.cpp delete mode 100644 src/browsermainwindow.h create mode 100644 src/mainwindow.cpp create mode 100644 src/mainwindow.h delete mode 100644 src/tags diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d53a7add..51790586 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ SET( rekonq_SRCS autosaver.cpp browserapplication.cpp - browsermainwindow.cpp + mainwindow.cpp cookiejar.cpp downloadmanager.cpp edittableview.cpp diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index ec46dd53..63d15f7b 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -21,7 +21,7 @@ #include "bookmarks.h" #include "bookmarks.moc" -#include "browsermainwindow.h" +#include "mainwindow.h" #include "webview.h" // KDE Includes @@ -31,7 +31,7 @@ OwnBookMarks::OwnBookMarks(KMainWindow *parent) : QObject(parent) , KBookmarkOwner() { - m_parent = qobject_cast( parent ); + m_parent = qobject_cast( parent ); connect( this, SIGNAL( openUrl( const KUrl &) ) , parent , SLOT( loadUrl( const KUrl & ) ) ); } diff --git a/src/bookmarks.h b/src/bookmarks.h index 91160321..e0e49c78 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -29,7 +29,7 @@ #include #include -class BrowserMainWindow; +class MainWindow; class OwnBookMarks : public QObject , public KBookmarkOwner { @@ -47,7 +47,7 @@ signals: void openUrl(const KUrl &); private: - BrowserMainWindow *m_parent; + MainWindow *m_parent; }; diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 52c5e670..696b2cd8 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -22,7 +22,7 @@ // Local Includes #include "browserapplication.h" -#include "browsermainwindow.h" +#include "mainwindow.h" #include "cookiejar.h" #include "downloadmanager.h" #include "history.h" @@ -173,10 +173,10 @@ void BrowserApplication::loadSettings() -QList BrowserApplication::mainWindows() +QList BrowserApplication::mainWindows() { clean(); - QList list; + QList list; for (int i = 0; i < m_mainWindows.count(); ++i) { list.append(m_mainWindows.at(i)); @@ -247,7 +247,7 @@ void BrowserApplication::restoreLastSession() } for (int i = 0; i < windows.count(); ++i) { - BrowserMainWindow *newWindow = 0; + MainWindow *newWindow = 0; if (m_mainWindows.count() == 1 && mainWindow()->tabWidget()->count() == 1 && mainWindow()->currentTab()->url() == KUrl()) @@ -277,16 +277,16 @@ void BrowserApplication::openUrl(const KUrl &url) -BrowserMainWindow *BrowserApplication::newMainWindow() +MainWindow *BrowserApplication::newMainWindow() { - BrowserMainWindow *browser = new BrowserMainWindow(); + MainWindow *browser = new MainWindow(); m_mainWindows.prepend(browser); browser->show(); return browser; } -BrowserMainWindow *BrowserApplication::mainWindow() +MainWindow *BrowserApplication::mainWindow() { clean(); if (m_mainWindows.isEmpty()) diff --git a/src/browserapplication.h b/src/browserapplication.h index 7f2ef321..8d33883e 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -35,7 +35,7 @@ QT_BEGIN_NAMESPACE class QLocalServer; QT_END_NAMESPACE -class BrowserMainWindow; +class MainWindow; class CookieJar; class DownloadManager; class HistoryManager; @@ -52,8 +52,8 @@ public: void loadSettings(); bool isTheOnlyBrowser() const; - BrowserMainWindow *mainWindow(); - QList mainWindows(); + MainWindow *mainWindow(); + QList mainWindows(); KIcon icon(const KUrl &url) const; void saveSession(); @@ -65,7 +65,7 @@ public: static NetworkAccessManager *networkAccessManager(); public slots: - BrowserMainWindow *newMainWindow(); + MainWindow *newMainWindow(); void restoreLastSession(); private slots: @@ -80,7 +80,7 @@ private: static DownloadManager *s_downloadManager; static NetworkAccessManager *s_networkAccessManager; - QList > m_mainWindows; + QList > m_mainWindows; QLocalServer *m_localServer; QByteArray m_lastSession; mutable KIcon m_defaultIcon; diff --git a/src/browsermainwindow.cpp b/src/browsermainwindow.cpp deleted file mode 100644 index cafb45bd..00000000 --- a/src/browsermainwindow.cpp +++ /dev/null @@ -1,862 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -// Local Includes -#include "browsermainwindow.h" -#include "autosaver.h" -#include "browserapplication.h" -#include "downloadmanager.h" -#include "history.h" -#include "settings.h" -#include "tabwidget.h" -#include "bookmarks.h" -#include "webview.h" - -// UI Includes -#include "ui_passworddialog.h" - -// KDE Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Qt Includes -#include -#include -#include -#include -#include -#include -#include - - -BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags) - : KMainWindow(parent, flags) - , m_tabWidget(new TabWidget(this)) - , m_autoSaver(new AutoSaver(this)) - , m_historyBack(0) - , m_historyForward(0) - , m_stop(0) - , m_reload(0) -{ - // delete widget accepting close event - setAttribute(Qt::WA_DeleteOnClose, true); - - setupMenu(); - setupToolBar(); - - QWidget *centralWidget = new QWidget(this); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setSpacing(0); - layout->setMargin(0); - addToolBarBreak(); - layout->addWidget(m_tabWidget); - - // Find Bar - m_findBar = new FindBar(this); - connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); - - centralWidget->setLayout(layout); - setCentralWidget(centralWidget); - - connect(m_tabWidget, SIGNAL( loadPage(const QString &) ), this, SLOT( loadPage(const QString &) ) ); - connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); - connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); - connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); - connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); - connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); - connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); - connect(m_tabWidget, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); - connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) ); - connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); - - slotUpdateWindowTitle(); - loadDefaultState(); - m_tabWidget->newTab(); -} - - -BrowserMainWindow::~BrowserMainWindow() -{ - m_autoSaver->changeOccurred(); - m_autoSaver->saveIfNeccessary(); - delete m_navigationBar; -} - - -void BrowserMainWindow::loadDefaultState() -{ - KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("BrowserMainWindow"); - QByteArray data = group1.readEntry(QString("defaultState"), QByteArray() ); - restoreState(data); -} - - -void BrowserMainWindow::save() -{ - BrowserApplication::instance()->saveSession(); - - KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("BrowserMainWindow"); - QByteArray data = saveState(); - group1.writeEntry( QString("defaultState"), data ); - - KConfigGroup group2 = config.group("navigation toobar"); - m_navigationBar->saveSettings( group2 ); -} - - -static const qint32 BrowserMainWindowMagic = 0xba; - - -QByteArray BrowserMainWindow::saveState() const -{ - int version = 2; - QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); - - stream << qint32(BrowserMainWindowMagic); - stream << qint32(version); - - stream << size(); - - stream << KToolBar::toolBarsLocked(); - bool b = true; // statusBar()->isVisible() ; FIXME - stream << b; - stream << QByteArray(); - return data; -} - - - -void BrowserMainWindow::restoreState(const QByteArray &state) -{ - int version = 2; - QByteArray sd = state; - QDataStream stream(&sd, QIODevice::ReadOnly); - if ( stream.atEnd() ) - { - return; - } - - qint32 marker; - qint32 v; - stream >> marker; - stream >> v; - if (marker != BrowserMainWindowMagic || v != version) - { - return; - } - - QSize size; - bool showStatusbar; - bool toolbarsLocked; - QByteArray tabState; - - stream >> size; - stream >> toolbarsLocked; - stream >> showStatusbar; - - resize(size); - statusBar()->setVisible(showStatusbar); - updateStatusbarActionText(showStatusbar); - - KToolBar::setToolBarsLocked ( toolbarsLocked ); - return; -} - - -void BrowserMainWindow::setupMenu() -{ - // ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- - KMenu *fileMenu = (KMenu *) menuBar()->addMenu( i18n("&File") ); - - fileMenu->addAction( KStandardAction::openNew(this, SLOT( slotFileNew() ) , this ) ); - fileMenu->addAction( KStandardAction::open( this, SLOT( slotFileOpen() ), this ) ); - fileMenu->addAction( i18n("Open Location"), this, SLOT( slotSelectLineEdit() ) ); - fileMenu->addSeparator(); - - fileMenu->addAction( m_tabWidget->newTabAction() ); - fileMenu->addAction( m_tabWidget->closeTabAction() ); - fileMenu->addSeparator(); - - fileMenu->addAction( KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), this ) ); - fileMenu->addSeparator(); - - fileMenu->addAction( KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), this ) ); - fileMenu->addAction( KStandardAction::print( this, SLOT(slotFilePrint()), this) ); - fileMenu->addSeparator(); - - KAction *action = (KAction *) fileMenu->addAction( i18n("Private &Browsing..."), this, SLOT( slotPrivateBrowsing() ) ); - action->setCheckable(true); - fileMenu->addSeparator(); - - fileMenu->addAction( KStandardAction::quit( this , SLOT( close() ), this ) ); - - // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- - KMenu *editMenu = (KMenu *) menuBar()->addMenu( i18n("&Edit") ); - - KAction *m_undo = KStandardAction::undo( this , 0 , this ); - editMenu->addAction( m_undo ); - m_tabWidget->addWebAction(m_undo, QWebPage::Undo); - - KAction *m_redo = KStandardAction::redo( this , 0 , this ); - editMenu->addAction( m_redo ); - m_tabWidget->addWebAction(m_redo, QWebPage::Redo); - - editMenu->addSeparator(); - - KAction *m_cut = KStandardAction::cut( this , 0 , this ); - editMenu->addAction( m_cut ); - m_tabWidget->addWebAction(m_cut, QWebPage::Cut); - - KAction *m_copy = KStandardAction::copy( this , 0 , this ); - editMenu->addAction( m_copy ); - m_tabWidget->addWebAction(m_copy, QWebPage::Copy); - - KAction *m_paste = KStandardAction::paste( this , 0 , this ); - editMenu->addAction( m_paste ); - m_tabWidget->addWebAction(m_paste, QWebPage::Paste); - - editMenu->addSeparator(); - - KAction *m_selectall = KStandardAction::selectAll( this , 0 , this ); - editMenu->addAction( m_selectall ); - m_tabWidget->addWebAction(m_selectall, QWebPage::SelectEndOfDocument ); - - editMenu->addSeparator(); - - editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); - editMenu->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); - - // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- - KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); - - m_viewStatusbar = KStandardAction::showStatusbar( this, SLOT(slotViewStatusbar() ), this); - viewMenu->addAction(m_viewStatusbar); - - viewMenu->addSeparator(); - - m_stop = (KAction *) viewMenu->addAction( KIcon( "process-stop" ), i18n("&Stop") ); - m_stop->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); - m_tabWidget->addWebAction(m_stop, QWebPage::Stop); - - m_reload = (KAction *) viewMenu->addAction( KIcon("view-refresh"), i18n("Reload Page") ); - m_reload->setShortcut(QKeySequence::Refresh); - m_tabWidget->addWebAction(m_reload, QWebPage::Reload); - - viewMenu->addSeparator(); - - KMenu *fontMenu = new KMenu( i18n("Make Text..."), this ); - fontMenu->addAction( i18n("&Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); - fontMenu->addAction( i18n("&Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); - fontMenu->addAction( i18n("&Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); - - viewMenu->addMenu( fontMenu ); - - viewMenu->addSeparator(); - - // TODO set encoding - - viewMenu->addAction( i18n("Page S&ource"), this, SLOT( slotViewPageSource() ), i18n("Ctrl+Alt+U")); - - KToggleFullScreenAction *tfsa = KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, this); - viewMenu->addAction( tfsa ); - - // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- - HistoryMenu *historyMenu = new HistoryMenu(this); - connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); - connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); - historyMenu->setTitle( i18n("Hi&story") ); - menuBar()->addMenu(historyMenu); - QList historyActions; - - m_historyBack = new KAction( i18n("Back"), this); - m_historyBack->setShortcut( KShortcut( QKeySequence::Back ) ); - m_tabWidget->addWebAction( m_historyBack, QWebPage::Back ); - m_historyBack->setIconVisibleInMenu(false); - - m_historyForward = new KAction( i18n("Forward"), this); - m_historyForward->setShortcut( KShortcut( QKeySequence::Forward ) ); - m_tabWidget->addWebAction( m_historyForward, QWebPage::Forward ); - m_historyForward->setIconVisibleInMenu(false); - - historyActions.append( m_historyBack ); - historyActions.append( m_historyForward ); - historyActions.append( KStandardAction::home(this, SLOT( slotHome() ) , this ) ); - historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); - - historyMenu->setInitialActions(historyActions); - - - - // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- - - BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); - bookmarksMenu->setTitle( i18n("&Bookmarks") ); - menuBar()->addMenu( bookmarksMenu ); - - // ------------------------------------------------------------- TOOLS ------------------------------------------------------------------------------------------------------ - KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); - - toolsMenu->addAction( i18n("Downloads"), this, SLOT( slotDownloadManager() ), i18n("Alt+Ctrl+D") ); - - toolsMenu->addSeparator(); - - action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); - action->setCheckable(true); - - // ------------------------------------------------------------- SETTINGS ------------------------------------------------------------------------------------------------------ - KMenu *settingsMenu = (KMenu *) menuBar()->addMenu( i18n("&Settings") ); - - settingsMenu->addAction( KStandardAction::keyBindings( this, SLOT( configureShortcuts() ), this ) ); //FIXME need new slot and actionCollection !! - settingsMenu->addAction( KStandardAction::preferences(this, SLOT( slotPreferences() ) , this ) ); - - // ------------------------------------------------------------- HELP -------------------------------------------------------------------------------------------------- - menuBar()->addMenu( helpMenu() ); -} - - -void BrowserMainWindow::setupToolBar() -{ - m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, true); - - m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); - m_historyBackMenu = new KMenu(this); - m_historyBack->setMenu(m_historyBackMenu); - connect(m_historyBack, SIGNAL( triggered() ), this, SLOT( slotOpenPrevious() ) ); - connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); - connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - m_navigationBar->addAction(m_historyBack); - - m_historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); - connect(m_historyForward, SIGNAL( triggered() ), this, SLOT( slotOpenNext() ) ); - m_navigationBar->addAction(m_historyForward); - - m_stopReload = new KAction( KIcon("view-refresh"), i18n("Reload"), this); - m_navigationBar->addAction(m_stopReload); - - m_goHome = new KAction( KIcon( "go-home" ), i18n("Home"),this); - m_navigationBar->addAction(m_goHome); - connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); - - m_navigationBar->addWidget( m_tabWidget->lineEditStack() ); - - m_searchBar = new SearchBar( m_navigationBar ); - connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); - m_navigationBar->addWidget(m_searchBar); - - // UI settings - setContextMenuPolicy( Qt::PreventContextMenu ); - - // setting initial style (if user hasn't decided something else) - m_navigationBar->setIconDimensions(22); - m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly ); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("navigation toobar"); - if ( group.exists() ) - { - m_navigationBar->applySettings( group ); - } -} - - -void BrowserMainWindow::updateStatusbarActionText(bool visible) -{ - m_viewStatusbar->setText(!visible ? i18n("Show Status Bar") : i18n("Hide Status Bar")); -} - - -void BrowserMainWindow::slotViewStatusbar() -{ - if (statusBar()->isVisible()) - { - updateStatusbarActionText(false); - statusBar()->close(); - } - else - { - updateStatusbarActionText(true); - statusBar()->show(); - } - m_autoSaver->changeOccurred(); -} - - -KUrl BrowserMainWindow::guessUrlFromString(const QString &string) -{ - QString urlStr = string.trimmed(); - QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); - - // Check if it looks like a qualified URL. Try parsing it and see. - bool hasSchema = test.exactMatch(urlStr); - if (hasSchema) - { - QUrl qurl(urlStr, QUrl::TolerantMode); - KUrl url(qurl); - if ( url.isValid() ) - { - return url; - } - } - - // Might be a file. - if (QFile::exists(urlStr)) - { - QFileInfo info(urlStr); - return KUrl::fromPath( info.absoluteFilePath() ); - } - - // Might be a shorturl - try to detect the schema. - if (!hasSchema) - { - int dotIndex = urlStr.indexOf(QLatin1Char('.')); - if (dotIndex != -1) - { - QString prefix = urlStr.left(dotIndex).toLower(); - QString schema = (prefix == QLatin1String("ftp")) ? prefix : QLatin1String("http"); - QUrl qurl(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode); - KUrl url(qurl); - if ( url.isValid() ) - { - return url; - } - } - } - - // Fall back to QUrl's own tolerant parser. - QUrl qurl = QUrl(string, QUrl::TolerantMode); - KUrl url(qurl); - - // finally for cases where the user just types in a hostname add http - if ( qurl.scheme().isEmpty() ) - { - qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode); - url = KUrl(qurl); - } - return url; -} - - -void BrowserMainWindow::loadUrl(const KUrl &url) -{ - loadPage( url.url() ); -} - - -void BrowserMainWindow::slotDownloadManager() -{ - BrowserApplication::downloadManager()->show(); -} - - -void BrowserMainWindow::slotSelectLineEdit() -{ - m_tabWidget->currentLineEdit()->selectAll(); - m_tabWidget->currentLineEdit()->setFocus(); -} - - -void BrowserMainWindow::slotFileSaveAs() -{ - BrowserApplication::downloadManager()->download(currentTab()->url(), true); -} - - -void BrowserMainWindow::slotPreferences() -{ - SettingsDialog *s = new SettingsDialog(this); - s->show(); -} - - -void BrowserMainWindow::slotUpdateStatusbar(const QString &string) -{ - statusBar()->showMessage(string, 2000); -} - - -void BrowserMainWindow::slotUpdateWindowTitle(const QString &title) -{ - if (title.isEmpty()) - { - setWindowTitle("rekonq"); - } - else - { - setWindowTitle(title + " - rekonq"); - } -} - - -void BrowserMainWindow::slotFileNew() -{ - BrowserApplication::instance()->newMainWindow(); - BrowserMainWindow *mw = BrowserApplication::instance()->mainWindow(); - mw->slotHome(); -} - - -void BrowserMainWindow::slotFileOpen() -{ - QString file = KFileDialog::getOpenFileName( KUrl(), - i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), - this, - i18n("Open Web Resource") ); - - if (file.isEmpty()) - return; - - loadPage(file); -} - - -void BrowserMainWindow::slotFilePrintPreview() -{ - if (!currentTab()) - return; - QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this); - connect(dialog, SIGNAL(paintRequested(QPrinter *)), currentTab(), SLOT(print(QPrinter *))); - dialog->exec(); -} - - -void BrowserMainWindow::slotFilePrint() -{ - if (!currentTab()) - return; - printRequested(currentTab()->page()->mainFrame()); -} - - -void BrowserMainWindow::printRequested(QWebFrame *frame) -{ - QPrinter printer; - QPrintDialog *dialog = new QPrintDialog(&printer, this); - dialog->setWindowTitle( i18n("Print Document") ); - if (dialog->exec() != QDialog::Accepted ) - return; - frame->print(&printer); -} - - -void BrowserMainWindow::slotPrivateBrowsing() -{ - QWebSettings *settings = QWebSettings::globalSettings(); - bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); - if (!pb) - { - QString title = i18n("Are you sure you want to turn on private browsing?"); - QString text = "" + title + i18n("

When private browsing in turned on," - " webpages are not added to the history," - " items are automatically removed from the Downloads window," \ - " new cookies are not stored, current cookies can't be accessed," \ - " site icons wont be stored, session wont be saved, " \ - " and searches are not addded to the pop-up menu in the Google search box." \ - " Until you close the window, you can still click the Back and Forward buttons" \ - " to return to the webpages you have opened."); - - int button = KMessageBox::questionYesNo( this, text, title ); - if (button == KMessageBox::Ok) - { - settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); - } - } - else - { - settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); - - QList windows = BrowserApplication::instance()->mainWindows(); - for (int i = 0; i < windows.count(); ++i) - { - BrowserMainWindow *window = windows.at(i); - window->m_lastSearch = QString::null; - window->tabWidget()->clear(); - } - } -} - - -void BrowserMainWindow::closeEvent(QCloseEvent *event) -{ - if (m_tabWidget->count() > 1) - { - int ret = KMessageBox::warningYesNo(this, - i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , - i18n("Closing") ); - if (ret == KMessageBox::No) - { - event->ignore(); - return; - } - } - event->accept(); - deleteLater(); -} - - -void BrowserMainWindow::slotFind(const QString & search) -{ - if (!currentTab()) - return; - if (!search.isEmpty()) - { - m_lastSearch = search; - if (!currentTab()->findText(m_lastSearch)) - slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); - } -} - - -void BrowserMainWindow::slotViewFindBar() -{ - m_findBar->showFindBar(); -} - - -void BrowserMainWindow::slotFindNext() -{ - if (!currentTab() && !m_lastSearch.isEmpty()) - return; - currentTab()->findText(m_lastSearch); -} - - -void BrowserMainWindow::slotFindPrevious() -{ - if (!currentTab() && !m_lastSearch.isEmpty()) - return; - currentTab()->findText(m_lastSearch, QWebPage::FindBackward); -} - - -void BrowserMainWindow::slotViewTextBigger() -{ - if (!currentTab()) - return; - currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() + 0.1); -} - - -void BrowserMainWindow::slotViewTextNormal() -{ - if (!currentTab()) - return; - currentTab()->setTextSizeMultiplier(1.0); -} - - -void BrowserMainWindow::slotViewTextSmaller() -{ - if (!currentTab()) - return; - currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() - 0.1); -} - - -// TODO improve this -void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen) -{ - KToggleFullScreenAction::setFullScreen( this, makeFullScreen ); -} - - -void BrowserMainWindow::slotViewPageSource() -{ - if (!currentTab()) - return; - - QString markup = currentTab()->page()->mainFrame()->toHtml(); - QPlainTextEdit *view = new QPlainTextEdit(markup); - view->setWindowTitle( i18n("Page Source of ") + currentTab()->title() ); - view->setMinimumWidth(640); - view->setAttribute(Qt::WA_DeleteOnClose); - view->show(); -} - - -void BrowserMainWindow::slotHome() -{ - KConfig config("rekonqrc"); - KConfigGroup group = config.group("Global Settings"); - QString home = group.readEntry( QString("home"), QString("http://www.kde.org/") ); - loadPage(home); -} - - -void BrowserMainWindow::slotToggleInspector(bool enable) -{ - QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); - if (enable) - { - int result = KMessageBox::questionYesNo(this, - i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" - "Do you want to reload all pages?"), - i18n("Web Inspector") ); - if (result == KMessageBox::Yes) - { - m_tabWidget->reloadAllTabs(); - } - } -} - - -void BrowserMainWindow::slotSwapFocus() -{ - if (currentTab()->hasFocus()) - m_tabWidget->currentLineEdit()->setFocus(); - else - currentTab()->setFocus(); -} - - -void BrowserMainWindow::loadPage(const QString &page) -{ - if (!currentTab() || page.isEmpty()) - return; - - KUrl url = guessUrlFromString(page); - m_tabWidget->currentLineEdit()->setText( url.prettyUrl() ); - m_tabWidget->loadUrlInCurrentTab(url); -} - - -TabWidget *BrowserMainWindow::tabWidget() const -{ - return m_tabWidget; -} - - - -WebView *BrowserMainWindow::currentTab() const -{ - return m_tabWidget->currentWebView(); -} - - -void BrowserMainWindow::slotLoadProgress(int progress) -{ - if (progress < 100 && progress > 0) - { - disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); - if (m_stopIcon.isNull()) - m_stopIcon = KIcon( "process-stop" ); - m_stopReload->setIcon(m_stopIcon); - connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); - m_stopReload->setToolTip( i18n("Stop loading the current page") ); - } - else - { - disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); - m_stopReload->setIcon( KIcon("view-refresh") ); - connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); - m_stopReload->setToolTip( i18n("Reload the current page") ); - } -} - - -void BrowserMainWindow::slotAboutToShowBackMenu() -{ - m_historyBackMenu->clear(); - if (!currentTab()) - return; - QWebHistory *history = currentTab()->history(); - int historyCount = history->count(); - for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) - { - QWebHistoryItem item = history->backItems(history->count()).at(i); - KAction *action = new KAction(this); - action->setData(-1*(historyCount-i-1)); - QIcon icon = BrowserApplication::instance()->icon(item.url()); - action->setIcon(icon); - action->setText(item.title()); - m_historyBackMenu->addAction(action); - } -} - - -void BrowserMainWindow::slotShowWindow() -{ - if (KAction *action = qobject_cast(sender())) - { - QVariant v = action->data(); - if (v.canConvert()) - { - int offset = qvariant_cast(v); - QList windows = BrowserApplication::instance()->mainWindows(); - windows.at(offset)->activateWindow(); - windows.at(offset)->currentTab()->setFocus(); - } - } -} - - -void BrowserMainWindow::slotOpenActionUrl(QAction *action) -{ - int offset = action->data().toInt(); - QWebHistory *history = currentTab()->history(); - if (offset < 0) - { - history->goToItem(history->backItems(-1*offset).first()); // back - } - else - { - if (offset > 0) - { - history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward - } - } -} - - -void BrowserMainWindow::slotOpenPrevious() -{ - QWebHistory *history = currentTab()->history(); - if ( history->canGoBack() ) - history->goToItem( history->backItem() ); -} - - -void BrowserMainWindow::slotOpenNext() -{ - QWebHistory *history = currentTab()->history(); - if ( history->canGoForward() ) - history->goToItem( history->forwardItem() ); -} - - -void BrowserMainWindow::geometryChangeRequested(const QRect &geometry) -{ - setGeometry(geometry); -} - diff --git a/src/browsermainwindow.h b/src/browsermainwindow.h deleted file mode 100644 index 3bd80168..00000000 --- a/src/browsermainwindow.h +++ /dev/null @@ -1,149 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -#ifndef BROWSERMAINWINDOW_H -#define BROWSERMAINWINDOW_H - -// Local Includes -#include "findbar.h" -#include "searchbar.h" - -// KDE Includes -#include -#include -#include -#include -#include -#include -#include - - -class AutoSaver; -class QWebFrame; -class TabWidget; -class WebView; - -/** - The MainWindow of the Browser Application. - Handles the tab widget and all the actions -*/ -class BrowserMainWindow : public KMainWindow -{ - Q_OBJECT - -public: - BrowserMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); - ~BrowserMainWindow(); - - static KUrl guessUrlFromString(const QString &url); - TabWidget *tabWidget() const; - WebView *currentTab() const; - - - QByteArray saveState() const; - void restoreState(const QByteArray &state); - -public slots: - void loadPage(const QString &url); - void slotHome(); - void slotFind(const QString &); - void slotFindNext(); - void slotFindPrevious(); - -protected: - void closeEvent(QCloseEvent *event); - -private slots: - void save(); - - void slotLoadProgress(int); - void slotUpdateStatusbar(const QString &string); - void slotUpdateWindowTitle(const QString &title = QString()); - - void loadUrl(const KUrl &url); - void slotPreferences(); - - void slotFileNew(); - void slotFileOpen(); - void slotFilePrintPreview(); - void slotFilePrint(); - void slotPrivateBrowsing(); - void slotFileSaveAs(); - - void slotViewTextBigger(); - void slotViewTextNormal(); - void slotViewTextSmaller(); - void slotViewStatusbar(); - void slotViewPageSource(); - void slotViewFullScreen(bool enable); - void slotViewFindBar(); - - void slotToggleInspector(bool enable); - void slotDownloadManager(); - void slotSelectLineEdit(); - - void slotAboutToShowBackMenu(); - - // history related - void slotOpenActionUrl(QAction *action); - void slotOpenPrevious(); - void slotOpenNext(); - - void slotShowWindow(); - void slotSwapFocus(); - - void printRequested(QWebFrame *frame); - void geometryChangeRequested(const QRect &geometry); - -private: - void loadDefaultState(); - void setupMenu(); - void setupToolBar(); - void updateStatusbarActionText(bool visible); - -private: - - KToolBar *m_navigationBar; - SearchBar *m_searchBar; - TabWidget *m_tabWidget; - AutoSaver *m_autoSaver; - - KAction *m_historyBack; - KMenu *m_historyBackMenu; - KAction *m_historyForward; - KMenu *m_windowMenu; - - KAction *m_stop; - KAction *m_reload; - KAction *m_stopReload; - KAction *m_goHome; - KToggleAction *m_viewStatusbar; - KAction *m_restoreLastSession; - - KIcon m_reloadIcon; - KIcon m_stopIcon; - - FindBar *m_findBar; - QString m_lastSearch; -}; - -#endif // BROWSERMAINWINDOW_H - diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 00000000..b57f5379 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,862 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes +#include "mainwindow.h" +#include "autosaver.h" +#include "browserapplication.h" +#include "downloadmanager.h" +#include "history.h" +#include "settings.h" +#include "tabwidget.h" +#include "bookmarks.h" +#include "webview.h" + +// UI Includes +#include "ui_passworddialog.h" + +// KDE Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Qt Includes +#include +#include +#include +#include +#include +#include +#include + + +MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) + : KMainWindow(parent, flags) + , m_tabWidget(new TabWidget(this)) + , m_autoSaver(new AutoSaver(this)) + , m_historyBack(0) + , m_historyForward(0) + , m_stop(0) + , m_reload(0) +{ + // delete widget accepting close event + setAttribute(Qt::WA_DeleteOnClose, true); + + setupMenu(); + setupToolBar(); + + QWidget *centralWidget = new QWidget(this); + + QVBoxLayout *layout = new QVBoxLayout; + layout->setSpacing(0); + layout->setMargin(0); + addToolBarBreak(); + layout->addWidget(m_tabWidget); + + // Find Bar + m_findBar = new FindBar(this); + connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); + + centralWidget->setLayout(layout); + setCentralWidget(centralWidget); + + connect(m_tabWidget, SIGNAL( loadPage(const QString &) ), this, SLOT( loadPage(const QString &) ) ); + connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); + connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); + connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); + connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); + connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); + connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); + connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); + connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); + connect(m_tabWidget, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); + connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) ); + connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); + + slotUpdateWindowTitle(); + loadDefaultState(); + m_tabWidget->newTab(); +} + + +MainWindow::~MainWindow() +{ + m_autoSaver->changeOccurred(); + m_autoSaver->saveIfNeccessary(); + delete m_navigationBar; +} + + +void MainWindow::loadDefaultState() +{ + KConfig config("rekonqrc"); + KConfigGroup group1 = config.group("MainWindow"); + QByteArray data = group1.readEntry(QString("defaultState"), QByteArray() ); + restoreState(data); +} + + +void MainWindow::save() +{ + BrowserApplication::instance()->saveSession(); + + KConfig config("rekonqrc"); + KConfigGroup group1 = config.group("MainWindow"); + QByteArray data = saveState(); + group1.writeEntry( QString("defaultState"), data ); + + KConfigGroup group2 = config.group("navigation toobar"); + m_navigationBar->saveSettings( group2 ); +} + + +static const qint32 MainWindowMagic = 0xba; + + +QByteArray MainWindow::saveState() const +{ + int version = 2; + QByteArray data; + QDataStream stream(&data, QIODevice::WriteOnly); + + stream << qint32(MainWindowMagic); + stream << qint32(version); + + stream << size(); + + stream << KToolBar::toolBarsLocked(); + bool b = true; // statusBar()->isVisible() ; FIXME + stream << b; + stream << QByteArray(); + return data; +} + + + +void MainWindow::restoreState(const QByteArray &state) +{ + int version = 2; + QByteArray sd = state; + QDataStream stream(&sd, QIODevice::ReadOnly); + if ( stream.atEnd() ) + { + return; + } + + qint32 marker; + qint32 v; + stream >> marker; + stream >> v; + if (marker != MainWindowMagic || v != version) + { + return; + } + + QSize size; + bool showStatusbar; + bool toolbarsLocked; + QByteArray tabState; + + stream >> size; + stream >> toolbarsLocked; + stream >> showStatusbar; + + resize(size); + statusBar()->setVisible(showStatusbar); + updateStatusbarActionText(showStatusbar); + + KToolBar::setToolBarsLocked ( toolbarsLocked ); + return; +} + + +void MainWindow::setupMenu() +{ + // ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- + KMenu *fileMenu = (KMenu *) menuBar()->addMenu( i18n("&File") ); + + fileMenu->addAction( KStandardAction::openNew(this, SLOT( slotFileNew() ) , this ) ); + fileMenu->addAction( KStandardAction::open( this, SLOT( slotFileOpen() ), this ) ); + fileMenu->addAction( i18n("Open Location"), this, SLOT( slotSelectLineEdit() ) ); + fileMenu->addSeparator(); + + fileMenu->addAction( m_tabWidget->newTabAction() ); + fileMenu->addAction( m_tabWidget->closeTabAction() ); + fileMenu->addSeparator(); + + fileMenu->addAction( KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), this ) ); + fileMenu->addSeparator(); + + fileMenu->addAction( KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), this ) ); + fileMenu->addAction( KStandardAction::print( this, SLOT(slotFilePrint()), this) ); + fileMenu->addSeparator(); + + KAction *action = (KAction *) fileMenu->addAction( i18n("Private &Browsing..."), this, SLOT( slotPrivateBrowsing() ) ); + action->setCheckable(true); + fileMenu->addSeparator(); + + fileMenu->addAction( KStandardAction::quit( this , SLOT( close() ), this ) ); + + // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- + KMenu *editMenu = (KMenu *) menuBar()->addMenu( i18n("&Edit") ); + + KAction *m_undo = KStandardAction::undo( this , 0 , this ); + editMenu->addAction( m_undo ); + m_tabWidget->addWebAction(m_undo, QWebPage::Undo); + + KAction *m_redo = KStandardAction::redo( this , 0 , this ); + editMenu->addAction( m_redo ); + m_tabWidget->addWebAction(m_redo, QWebPage::Redo); + + editMenu->addSeparator(); + + KAction *m_cut = KStandardAction::cut( this , 0 , this ); + editMenu->addAction( m_cut ); + m_tabWidget->addWebAction(m_cut, QWebPage::Cut); + + KAction *m_copy = KStandardAction::copy( this , 0 , this ); + editMenu->addAction( m_copy ); + m_tabWidget->addWebAction(m_copy, QWebPage::Copy); + + KAction *m_paste = KStandardAction::paste( this , 0 , this ); + editMenu->addAction( m_paste ); + m_tabWidget->addWebAction(m_paste, QWebPage::Paste); + + editMenu->addSeparator(); + + KAction *m_selectall = KStandardAction::selectAll( this , 0 , this ); + editMenu->addAction( m_selectall ); + m_tabWidget->addWebAction(m_selectall, QWebPage::SelectEndOfDocument ); + + editMenu->addSeparator(); + + editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); + editMenu->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); + editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); + + // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- + KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); + + m_viewStatusbar = KStandardAction::showStatusbar( this, SLOT(slotViewStatusbar() ), this); + viewMenu->addAction(m_viewStatusbar); + + viewMenu->addSeparator(); + + m_stop = (KAction *) viewMenu->addAction( KIcon( "process-stop" ), i18n("&Stop") ); + m_stop->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); + m_tabWidget->addWebAction(m_stop, QWebPage::Stop); + + m_reload = (KAction *) viewMenu->addAction( KIcon("view-refresh"), i18n("Reload Page") ); + m_reload->setShortcut(QKeySequence::Refresh); + m_tabWidget->addWebAction(m_reload, QWebPage::Reload); + + viewMenu->addSeparator(); + + KMenu *fontMenu = new KMenu( i18n("Make Text..."), this ); + fontMenu->addAction( i18n("&Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); + fontMenu->addAction( i18n("&Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); + fontMenu->addAction( i18n("&Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); + + viewMenu->addMenu( fontMenu ); + + viewMenu->addSeparator(); + + // TODO set encoding + + viewMenu->addAction( i18n("Page S&ource"), this, SLOT( slotViewPageSource() ), i18n("Ctrl+Alt+U")); + + KToggleFullScreenAction *tfsa = KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, this); + viewMenu->addAction( tfsa ); + + // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- + HistoryMenu *historyMenu = new HistoryMenu(this); + connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); + connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); + historyMenu->setTitle( i18n("Hi&story") ); + menuBar()->addMenu(historyMenu); + QList historyActions; + + m_historyBack = new KAction( i18n("Back"), this); + m_historyBack->setShortcut( KShortcut( QKeySequence::Back ) ); + m_tabWidget->addWebAction( m_historyBack, QWebPage::Back ); + m_historyBack->setIconVisibleInMenu(false); + + m_historyForward = new KAction( i18n("Forward"), this); + m_historyForward->setShortcut( KShortcut( QKeySequence::Forward ) ); + m_tabWidget->addWebAction( m_historyForward, QWebPage::Forward ); + m_historyForward->setIconVisibleInMenu(false); + + historyActions.append( m_historyBack ); + historyActions.append( m_historyForward ); + historyActions.append( KStandardAction::home(this, SLOT( slotHome() ) , this ) ); + historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); + + historyMenu->setInitialActions(historyActions); + + + + // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- + + BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); + bookmarksMenu->setTitle( i18n("&Bookmarks") ); + menuBar()->addMenu( bookmarksMenu ); + + // ------------------------------------------------------------- TOOLS ------------------------------------------------------------------------------------------------------ + KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); + + toolsMenu->addAction( i18n("Downloads"), this, SLOT( slotDownloadManager() ), i18n("Alt+Ctrl+D") ); + + toolsMenu->addSeparator(); + + action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); + action->setCheckable(true); + + // ------------------------------------------------------------- SETTINGS ------------------------------------------------------------------------------------------------------ + KMenu *settingsMenu = (KMenu *) menuBar()->addMenu( i18n("&Settings") ); + + settingsMenu->addAction( KStandardAction::keyBindings( this, SLOT( configureShortcuts() ), this ) ); //FIXME need new slot and actionCollection !! + settingsMenu->addAction( KStandardAction::preferences(this, SLOT( slotPreferences() ) , this ) ); + + // ------------------------------------------------------------- HELP -------------------------------------------------------------------------------------------------- + menuBar()->addMenu( helpMenu() ); +} + + +void MainWindow::setupToolBar() +{ + m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, true); + + m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); + m_historyBackMenu = new KMenu(this); + m_historyBack->setMenu(m_historyBackMenu); + connect(m_historyBack, SIGNAL( triggered() ), this, SLOT( slotOpenPrevious() ) ); + connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); + connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); + m_navigationBar->addAction(m_historyBack); + + m_historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); + connect(m_historyForward, SIGNAL( triggered() ), this, SLOT( slotOpenNext() ) ); + m_navigationBar->addAction(m_historyForward); + + m_stopReload = new KAction( KIcon("view-refresh"), i18n("Reload"), this); + m_navigationBar->addAction(m_stopReload); + + m_goHome = new KAction( KIcon( "go-home" ), i18n("Home"),this); + m_navigationBar->addAction(m_goHome); + connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); + + m_navigationBar->addWidget( m_tabWidget->lineEditStack() ); + + m_searchBar = new SearchBar( m_navigationBar ); + connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + m_navigationBar->addWidget(m_searchBar); + + // UI settings + setContextMenuPolicy( Qt::PreventContextMenu ); + + // setting initial style (if user hasn't decided something else) + m_navigationBar->setIconDimensions(22); + m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly ); + + KConfig config("rekonqrc"); + KConfigGroup group = config.group("navigation toobar"); + if ( group.exists() ) + { + m_navigationBar->applySettings( group ); + } +} + + +void MainWindow::updateStatusbarActionText(bool visible) +{ + m_viewStatusbar->setText(!visible ? i18n("Show Status Bar") : i18n("Hide Status Bar")); +} + + +void MainWindow::slotViewStatusbar() +{ + if (statusBar()->isVisible()) + { + updateStatusbarActionText(false); + statusBar()->close(); + } + else + { + updateStatusbarActionText(true); + statusBar()->show(); + } + m_autoSaver->changeOccurred(); +} + + +KUrl MainWindow::guessUrlFromString(const QString &string) +{ + QString urlStr = string.trimmed(); + QRegExp test(QLatin1String("^[a-zA-Z]+\\:.*")); + + // Check if it looks like a qualified URL. Try parsing it and see. + bool hasSchema = test.exactMatch(urlStr); + if (hasSchema) + { + QUrl qurl(urlStr, QUrl::TolerantMode); + KUrl url(qurl); + if ( url.isValid() ) + { + return url; + } + } + + // Might be a file. + if (QFile::exists(urlStr)) + { + QFileInfo info(urlStr); + return KUrl::fromPath( info.absoluteFilePath() ); + } + + // Might be a shorturl - try to detect the schema. + if (!hasSchema) + { + int dotIndex = urlStr.indexOf(QLatin1Char('.')); + if (dotIndex != -1) + { + QString prefix = urlStr.left(dotIndex).toLower(); + QString schema = (prefix == QLatin1String("ftp")) ? prefix : QLatin1String("http"); + QUrl qurl(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode); + KUrl url(qurl); + if ( url.isValid() ) + { + return url; + } + } + } + + // Fall back to QUrl's own tolerant parser. + QUrl qurl = QUrl(string, QUrl::TolerantMode); + KUrl url(qurl); + + // finally for cases where the user just types in a hostname add http + if ( qurl.scheme().isEmpty() ) + { + qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode); + url = KUrl(qurl); + } + return url; +} + + +void MainWindow::loadUrl(const KUrl &url) +{ + loadPage( url.url() ); +} + + +void MainWindow::slotDownloadManager() +{ + BrowserApplication::downloadManager()->show(); +} + + +void MainWindow::slotSelectLineEdit() +{ + m_tabWidget->currentLineEdit()->selectAll(); + m_tabWidget->currentLineEdit()->setFocus(); +} + + +void MainWindow::slotFileSaveAs() +{ + BrowserApplication::downloadManager()->download(currentTab()->url(), true); +} + + +void MainWindow::slotPreferences() +{ + SettingsDialog *s = new SettingsDialog(this); + s->show(); +} + + +void MainWindow::slotUpdateStatusbar(const QString &string) +{ + statusBar()->showMessage(string, 2000); +} + + +void MainWindow::slotUpdateWindowTitle(const QString &title) +{ + if (title.isEmpty()) + { + setWindowTitle("rekonq"); + } + else + { + setWindowTitle(title + " - rekonq"); + } +} + + +void MainWindow::slotFileNew() +{ + BrowserApplication::instance()->newMainWindow(); + MainWindow *mw = BrowserApplication::instance()->mainWindow(); + mw->slotHome(); +} + + +void MainWindow::slotFileOpen() +{ + QString file = KFileDialog::getOpenFileName( KUrl(), + i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), + this, + i18n("Open Web Resource") ); + + if (file.isEmpty()) + return; + + loadPage(file); +} + + +void MainWindow::slotFilePrintPreview() +{ + if (!currentTab()) + return; + QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this); + connect(dialog, SIGNAL(paintRequested(QPrinter *)), currentTab(), SLOT(print(QPrinter *))); + dialog->exec(); +} + + +void MainWindow::slotFilePrint() +{ + if (!currentTab()) + return; + printRequested(currentTab()->page()->mainFrame()); +} + + +void MainWindow::printRequested(QWebFrame *frame) +{ + QPrinter printer; + QPrintDialog *dialog = new QPrintDialog(&printer, this); + dialog->setWindowTitle( i18n("Print Document") ); + if (dialog->exec() != QDialog::Accepted ) + return; + frame->print(&printer); +} + + +void MainWindow::slotPrivateBrowsing() +{ + QWebSettings *settings = QWebSettings::globalSettings(); + bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); + if (!pb) + { + QString title = i18n("Are you sure you want to turn on private browsing?"); + QString text = "" + title + i18n("

When private browsing in turned on," + " webpages are not added to the history," + " items are automatically removed from the Downloads window," \ + " new cookies are not stored, current cookies can't be accessed," \ + " site icons wont be stored, session wont be saved, " \ + " and searches are not addded to the pop-up menu in the Google search box." \ + " Until you close the window, you can still click the Back and Forward buttons" \ + " to return to the webpages you have opened."); + + int button = KMessageBox::questionYesNo( this, text, title ); + if (button == KMessageBox::Ok) + { + settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); + } + } + else + { + settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); + + QList windows = BrowserApplication::instance()->mainWindows(); + for (int i = 0; i < windows.count(); ++i) + { + MainWindow *window = windows.at(i); + window->m_lastSearch = QString::null; + window->tabWidget()->clear(); + } + } +} + + +void MainWindow::closeEvent(QCloseEvent *event) +{ + if (m_tabWidget->count() > 1) + { + int ret = KMessageBox::warningYesNo(this, + i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , + i18n("Closing") ); + if (ret == KMessageBox::No) + { + event->ignore(); + return; + } + } + event->accept(); + deleteLater(); +} + + +void MainWindow::slotFind(const QString & search) +{ + if (!currentTab()) + return; + if (!search.isEmpty()) + { + m_lastSearch = search; + if (!currentTab()->findText(m_lastSearch)) + slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + } +} + + +void MainWindow::slotViewFindBar() +{ + m_findBar->showFindBar(); +} + + +void MainWindow::slotFindNext() +{ + if (!currentTab() && !m_lastSearch.isEmpty()) + return; + currentTab()->findText(m_lastSearch); +} + + +void MainWindow::slotFindPrevious() +{ + if (!currentTab() && !m_lastSearch.isEmpty()) + return; + currentTab()->findText(m_lastSearch, QWebPage::FindBackward); +} + + +void MainWindow::slotViewTextBigger() +{ + if (!currentTab()) + return; + currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() + 0.1); +} + + +void MainWindow::slotViewTextNormal() +{ + if (!currentTab()) + return; + currentTab()->setTextSizeMultiplier(1.0); +} + + +void MainWindow::slotViewTextSmaller() +{ + if (!currentTab()) + return; + currentTab()->setTextSizeMultiplier(currentTab()->textSizeMultiplier() - 0.1); +} + + +// TODO improve this +void MainWindow::slotViewFullScreen(bool makeFullScreen) +{ + KToggleFullScreenAction::setFullScreen( this, makeFullScreen ); +} + + +void MainWindow::slotViewPageSource() +{ + if (!currentTab()) + return; + + QString markup = currentTab()->page()->mainFrame()->toHtml(); + QPlainTextEdit *view = new QPlainTextEdit(markup); + view->setWindowTitle( i18n("Page Source of ") + currentTab()->title() ); + view->setMinimumWidth(640); + view->setAttribute(Qt::WA_DeleteOnClose); + view->show(); +} + + +void MainWindow::slotHome() +{ + KConfig config("rekonqrc"); + KConfigGroup group = config.group("Global Settings"); + QString home = group.readEntry( QString("home"), QString("http://www.kde.org/") ); + loadPage(home); +} + + +void MainWindow::slotToggleInspector(bool enable) +{ + QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); + if (enable) + { + int result = KMessageBox::questionYesNo(this, + i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" + "Do you want to reload all pages?"), + i18n("Web Inspector") ); + if (result == KMessageBox::Yes) + { + m_tabWidget->reloadAllTabs(); + } + } +} + + +void MainWindow::slotSwapFocus() +{ + if (currentTab()->hasFocus()) + m_tabWidget->currentLineEdit()->setFocus(); + else + currentTab()->setFocus(); +} + + +void MainWindow::loadPage(const QString &page) +{ + if (!currentTab() || page.isEmpty()) + return; + + KUrl url = guessUrlFromString(page); + m_tabWidget->currentLineEdit()->setText( url.prettyUrl() ); + m_tabWidget->loadUrlInCurrentTab(url); +} + + +TabWidget *MainWindow::tabWidget() const +{ + return m_tabWidget; +} + + + +WebView *MainWindow::currentTab() const +{ + return m_tabWidget->currentWebView(); +} + + +void MainWindow::slotLoadProgress(int progress) +{ + if (progress < 100 && progress > 0) + { + disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); + if (m_stopIcon.isNull()) + m_stopIcon = KIcon( "process-stop" ); + m_stopReload->setIcon(m_stopIcon); + connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); + m_stopReload->setToolTip( i18n("Stop loading the current page") ); + } + else + { + disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); + m_stopReload->setIcon( KIcon("view-refresh") ); + connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); + m_stopReload->setToolTip( i18n("Reload the current page") ); + } +} + + +void MainWindow::slotAboutToShowBackMenu() +{ + m_historyBackMenu->clear(); + if (!currentTab()) + return; + QWebHistory *history = currentTab()->history(); + int historyCount = history->count(); + for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) + { + QWebHistoryItem item = history->backItems(history->count()).at(i); + KAction *action = new KAction(this); + action->setData(-1*(historyCount-i-1)); + QIcon icon = BrowserApplication::instance()->icon(item.url()); + action->setIcon(icon); + action->setText(item.title()); + m_historyBackMenu->addAction(action); + } +} + + +void MainWindow::slotShowWindow() +{ + if (KAction *action = qobject_cast(sender())) + { + QVariant v = action->data(); + if (v.canConvert()) + { + int offset = qvariant_cast(v); + QList windows = BrowserApplication::instance()->mainWindows(); + windows.at(offset)->activateWindow(); + windows.at(offset)->currentTab()->setFocus(); + } + } +} + + +void MainWindow::slotOpenActionUrl(QAction *action) +{ + int offset = action->data().toInt(); + QWebHistory *history = currentTab()->history(); + if (offset < 0) + { + history->goToItem(history->backItems(-1*offset).first()); // back + } + else + { + if (offset > 0) + { + history->goToItem(history->forwardItems(history->count() - offset + 1).back()); // forward + } + } +} + + +void MainWindow::slotOpenPrevious() +{ + QWebHistory *history = currentTab()->history(); + if ( history->canGoBack() ) + history->goToItem( history->backItem() ); +} + + +void MainWindow::slotOpenNext() +{ + QWebHistory *history = currentTab()->history(); + if ( history->canGoForward() ) + history->goToItem( history->forwardItem() ); +} + + +void MainWindow::geometryChangeRequested(const QRect &geometry) +{ + setGeometry(geometry); +} + diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 00000000..6f78fd59 --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,149 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +// Local Includes +#include "findbar.h" +#include "searchbar.h" + +// KDE Includes +#include +#include +#include +#include +#include +#include +#include + + +class AutoSaver; +class QWebFrame; +class TabWidget; +class WebView; + +/** + The MainWindow of the Browser Application. + Handles the tab widget and all the actions +*/ +class MainWindow : public KMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + ~MainWindow(); + + static KUrl guessUrlFromString(const QString &url); + TabWidget *tabWidget() const; + WebView *currentTab() const; + + + QByteArray saveState() const; + void restoreState(const QByteArray &state); + +public slots: + void loadPage(const QString &url); + void slotHome(); + void slotFind(const QString &); + void slotFindNext(); + void slotFindPrevious(); + +protected: + void closeEvent(QCloseEvent *event); + +private slots: + void save(); + + void slotLoadProgress(int); + void slotUpdateStatusbar(const QString &string); + void slotUpdateWindowTitle(const QString &title = QString()); + + void loadUrl(const KUrl &url); + void slotPreferences(); + + void slotFileNew(); + void slotFileOpen(); + void slotFilePrintPreview(); + void slotFilePrint(); + void slotPrivateBrowsing(); + void slotFileSaveAs(); + + void slotViewTextBigger(); + void slotViewTextNormal(); + void slotViewTextSmaller(); + void slotViewStatusbar(); + void slotViewPageSource(); + void slotViewFullScreen(bool enable); + void slotViewFindBar(); + + void slotToggleInspector(bool enable); + void slotDownloadManager(); + void slotSelectLineEdit(); + + void slotAboutToShowBackMenu(); + + // history related + void slotOpenActionUrl(QAction *action); + void slotOpenPrevious(); + void slotOpenNext(); + + void slotShowWindow(); + void slotSwapFocus(); + + void printRequested(QWebFrame *frame); + void geometryChangeRequested(const QRect &geometry); + +private: + void loadDefaultState(); + void setupMenu(); + void setupToolBar(); + void updateStatusbarActionText(bool visible); + +private: + + KToolBar *m_navigationBar; + SearchBar *m_searchBar; + TabWidget *m_tabWidget; + AutoSaver *m_autoSaver; + + KAction *m_historyBack; + KMenu *m_historyBackMenu; + KAction *m_historyForward; + KMenu *m_windowMenu; + + KAction *m_stop; + KAction *m_reload; + KAction *m_stopReload; + KAction *m_goHome; + KToggleAction *m_viewStatusbar; + KAction *m_restoreLastSession; + + KIcon m_reloadIcon; + KIcon m_stopIcon; + + FindBar *m_findBar; + QString m_lastSearch; +}; + +#endif // MAINWINDOW_H + diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 869a6144..7390cd22 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -22,7 +22,7 @@ // Local Includes #include "networkaccessmanager.h" #include "browserapplication.h" -#include "browsermainwindow.h" +#include "mainwindow.h" #include "ui_passworddialog.h" #include "ui_proxy.h" @@ -84,7 +84,7 @@ void NetworkAccessManager::loadSettings() void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) { - BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); QDialog dialog(mainWindow); dialog.setWindowFlags(Qt::Sheet); @@ -108,7 +108,7 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth) { - BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); QDialog dialog(mainWindow); dialog.setWindowFlags(Qt::Sheet); @@ -133,7 +133,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox #ifndef QT_NO_OPENSSL void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList &error) { - BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); QStringList errorStrings; for (int i = 0; i < error.count(); ++i) diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 977703d3..c6889dba 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -22,7 +22,7 @@ #include "searchbar.moc" #include "browserapplication.h" -#include "browsermainwindow.h" +#include "mainwindow.h" #include diff --git a/src/settings.cpp b/src/settings.cpp index f765e18c..3b82935f 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -24,7 +24,7 @@ #include "settings.moc" #include "browserapplication.h" -#include "browsermainwindow.h" +#include "mainwindow.h" #include "cookiejar.h" #include "history.h" #include "networkaccessmanager.h" @@ -366,7 +366,7 @@ void SettingsDialog::chooseFixedFont() void SettingsDialog::setHomeToCurrentPage() { - BrowserMainWindow *mw = static_cast(parent()); + MainWindow *mw = static_cast(parent()); WebView *webView = mw->currentTab(); if (webView) { diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 06a14ff3..08ec1212 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -23,7 +23,7 @@ #include "tabwidget.h" #include "browserapplication.h" -#include "browsermainwindow.h" +#include "mainwindow.h" #include "history.h" #include "urlbar.h" #include "webview.h" diff --git a/src/tags b/src/tags deleted file mode 100644 index d2fc52eb..00000000 --- a/src/tags +++ /dev/null @@ -1,494 +0,0 @@ -!_TAG_FILE_FORMAT 2 /supported features/ -!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted/ -!_TAG_PROGRAM_AUTHOR Steve Kirkendall /kirkenda@cs.pdx.edu/ -!_TAG_PROGRAM_NAME Elvis Ctags // -!_TAG_PROGRAM_URL ftp://ftp.cs.pdx.edu/pub/elvis/README.html /official site/ -!_TAG_PROGRAM_VERSION 2.2.0 // -AUTOSAVER_H autosaver.h 22;" d ln:22 -AUTOSAVE_IN autosaver.cpp 28;" d ln:28 file: -AutoSaver autosaver.h /^class AutoSaver : public QObject {$/;" c ln:33 -AutoSaver browsermainwindow.h /^class AutoSaver;$/;" v ln:38 -AutoSaver cookiejar.h /^class AutoSaver;$/;" v ln:40 -AutoSaver downloadmanager.h /^class AutoSaver;$/;" v ln:74 -AutoSaver history.h /^class AutoSaver;$/;" v ln:67 -AutoSaver autosaver.cpp /^AutoSaver::AutoSaver(QObject *parent) : QObject(parent)$/;" f ln:31 class:AutoSaver -AutoSaver autosaver.cpp /^AutoSaver::~AutoSaver()$/;" f ln:36 class:AutoSaver -BOOKMARKS_H bookmarks.h 21;" d ln:21 -BROWSERAPPLICATION_H browserapplication.h 23;" d ln:23 -BROWSERMAINWINDOW_H browsermainwindow.h 23;" d ln:23 -BookmarksMenu bookmarks.h /^class BookmarksMenu : public KMenu$/;" c ln:54 -BookmarksMenu bookmarks.cpp /^BookmarksMenu::BookmarksMenu(KMainWindow *parent)$/;" f ln:61 class:BookmarksMenu -BrowserApplication browserapplication.h /^class BrowserApplication : public KApplication$/;" c ln:44 -BrowserApplication browserapplication.cpp /^BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &serverName)$/;" f ln:58 class:BrowserApplication -BrowserApplication browserapplication.cpp /^BrowserApplication::~BrowserApplication()$/;" f ln:102 class:BrowserApplication -BrowserMainWindow bookmarks.h /^class BrowserMainWindow;$/;" v ln:32 -BrowserMainWindow browserapplication.h /^class BrowserMainWindow;$/;" v ln:38 -BrowserMainWindow browsermainwindow.h /^class BrowserMainWindow : public KMainWindow $/;" c ln:48 -BrowserMainWindow webview.h /^class BrowserMainWindow;$/;" v ln:36 -BrowserMainWindow browsermainwindow.cpp /^BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags)$/;" f ln:61 class:BrowserMainWindow -BrowserMainWindow browsermainwindow.cpp /^BrowserMainWindow::~BrowserMainWindow()$/;" f ln:111 class:BrowserMainWindow -BrowserMainWindowMagic browsermainwindow.cpp /^static const qint32 BrowserMainWindowMagic = 0xba;$/;" v ln:150 file: -COOKIEJAR_H cookiejar.h 22;" d ln:22 -CookieExceptionsModel cookiejar.h /^class CookieExceptionsModel : public QAbstractTableModel$/;" c ln:155 -CookieExceptionsModel cookiejar.cpp /^CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent)$/;" f ln:574 class:CookieExceptionsModel -CookieJar browserapplication.h /^class CookieJar;$/;" v ln:39 -CookieJar cookiejar.h /^class CookieJar : public QNetworkCookieJar$/;" c ln:42 -CookieJar cookiejar.cpp /^CookieJar::CookieJar(QObject *parent)$/;" f ln:79 class:CookieJar -CookieJar cookiejar.cpp /^CookieJar::~CookieJar()$/;" f ln:87 class:CookieJar -CookieModel cookiejar.h /^class CookieModel : public QAbstractTableModel$/;" c ln:117 -CookieModel cookiejar.cpp /^CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent)$/;" f ln:407 class:CookieModel -CookiesDialog cookiejar.h /^class CookiesDialog : public QDialog, public Ui_CookiesDialog$/;" v ln:144 -CookiesDialog cookiejar.cpp /^CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) $/;" f ln:523 class:CookiesDialog -CookiesExceptionsDialog cookiejar.h /^class CookiesExceptionsDialog : public QDialog, public Ui_CookiesExceptionsDialog$/;" v ln:186 -CookiesExceptionsDialog cookiejar.cpp /^CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent)$/;" f ln:697 class:CookiesExceptionsDialog -DOWNLOADMANAGER_H downloadmanager.h 23;" d ln:23 -DownloadItem downloadmanager.h /^class DownloadItem : public QWidget, public Ui_DownloadItem$/;" v ln:33 -DownloadItem downloadmanager.cpp /^DownloadItem::DownloadItem(QNetworkReply *reply, bool requestFileName, QWidget *parent)$/;" f ln:46 class:DownloadItem -DownloadManager browserapplication.h /^class DownloadManager;$/;" v ln:40 -DownloadManager downloadmanager.h /^class DownloadManager : public QDialog, public Ui_DownloadDialog$/;" v ln:80 -DownloadManager downloadmanager.cpp /^DownloadManager::DownloadManager(QWidget *parent)$/;" f ln:307 class:DownloadManager -DownloadManager downloadmanager.cpp /^DownloadManager::~DownloadManager()$/;" f ln:326 class:DownloadManager -DownloadModel downloadmanager.h /^class DownloadModel;$/;" v ln:75 -DownloadModel downloadmanager.h /^class DownloadModel : public QAbstractListModel$/;" c ln:125 -DownloadModel downloadmanager.cpp /^DownloadModel::DownloadModel(DownloadManager *downloadManager, QObject *parent)$/;" f ln:506 class:DownloadModel -EDITTABLEVIEW_H edittableview.h 22;" d ln:22 -EDITTREEVIEW_H edittreeview.h 22;" d ln:22 -EditTableView edittableview.h /^class EditTableView : public QTableView$/;" c ln:26 -EditTableView edittableview.cpp /^EditTableView::EditTableView(QWidget *parent)$/;" f ln:24 class:EditTableView -EditTreeView edittreeview.h /^class EditTreeView : public QTreeView$/;" c ln:26 -EditTreeView edittreeview.cpp /^EditTreeView::EditTreeView(QWidget *parent)$/;" f ln:25 class:EditTreeView -FINDBAR_H findbar.h 21;" d ln:21 -FindBar findbar.h /^class FindBar : public KToolBar$/;" c ln:28 -FindBar findbar.cpp /^FindBar::FindBar(KMainWindow *parent)$/;" f ln:32 class:FindBar -FindBar findbar.cpp /^FindBar::~FindBar()$/;" f ln:59 class:FindBar -HISTORY_H history.h 23;" d ln:23 -HISTORY_VERSION history.cpp /^static const unsigned int HISTORY_VERSION = 23;$/;" v ln:39 file: -HistoryCompletionModel history.h /^class HistoryCompletionModel : public QAbstractProxyModel$/;" c ln:265 -HistoryCompletionModel history.cpp /^HistoryCompletionModel::HistoryCompletionModel(QObject *parent)$/;" f ln:981 class:HistoryCompletionModel -HistoryDialog history.h /^class HistoryDialog : public QDialog, public Ui_HistoryDialog$/;" v ln:342 -HistoryDialog history.cpp /^HistoryDialog::HistoryDialog(QWidget *parent, HistoryManager *setHistory) : QDialog(parent)$/;" f ln:698 class:HistoryDialog -HistoryFilterModel history.h /^class HistoryFilterModel;$/;" v ln:69 -HistoryFilterModel history.h /^class HistoryFilterModel : public QAbstractProxyModel$/;" c ln:168 -HistoryFilterModel history.cpp /^HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent)$/;" f ln:767 class:HistoryFilterModel -HistoryItem history.h /^class HistoryItem$/;" c ln:41 -HistoryManager browserapplication.h /^class HistoryManager;$/;" v ln:41 -HistoryManager history.h /^class HistoryManager : public QWebHistoryInterface$/;" c ln:73 -HistoryManager history.cpp /^HistoryManager::HistoryManager(QObject *parent)$/;" f ln:42 class:HistoryManager -HistoryManager history.cpp /^HistoryManager::~HistoryManager()$/;" f ln:65 class:HistoryManager -HistoryMenu history.h /^class HistoryMenu : public ModelMenu$/;" c ln:236 -HistoryMenu history.cpp /^HistoryMenu::HistoryMenu(QWidget *parent)$/;" f ln:614 class:HistoryMenu -HistoryMenuModel history.h /^class HistoryMenuModel : public QAbstractProxyModel$/;" c ln:214 -HistoryMenuModel history.cpp /^HistoryMenuModel::HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent)$/;" f ln:499 class:HistoryMenuModel -HistoryModel history.h /^class HistoryModel;$/;" v ln:68 -HistoryModel history.h /^class HistoryModel : public QAbstractTableModel$/;" c ln:133 -HistoryModel history.cpp /^HistoryModel::HistoryModel(HistoryManager *history, QObject *parent)$/;" f ln:373 class:HistoryModel -HistoryTreeModel history.h /^class HistoryTreeModel;$/;" v ln:70 -HistoryTreeModel history.h /^class HistoryTreeModel : public QAbstractProxyModel$/;" c ln:290 -HistoryTreeModel history.cpp /^HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent)$/;" f ln:1084 class:HistoryTreeModel -JAR_VERSION cookiejar.cpp /^static const unsigned int JAR_VERSION = 23;$/;" v ln:37 file: -KBookmarkOwner bookmarks.h /^class OwnBookMarks : public QObject , public KBookmarkOwner$/;" c ln:34 -MAXWAIT autosaver.cpp 29;" d ln:29 file: -MODELMENU_H modelmenu.h 23;" d ln:23 -MOVEDROWS history.cpp 494;" d ln:494 class:HistoryModel file: -ModelMenu modelmenu.h /^class ModelMenu : public QMenu$/;" c ln:34 -ModelMenu modelmenu.cpp /^ModelMenu::ModelMenu(QWidget * parent)$/;" f ln:24 class:ModelMenu -NETWORKACCESSMANAGER_H networkaccessmanager.h 22;" d ln:22 -NetworkAccessManager browserapplication.h /^class NetworkAccessManager;$/;" v ln:42 -NetworkAccessManager networkaccessmanager.h /^class NetworkAccessManager : public QNetworkAccessManager$/;" c ln:26 -NetworkAccessManager networkaccessmanager.cpp /^NetworkAccessManager::NetworkAccessManager(QObject *parent)$/;" f ln:43 class:NetworkAccessManager -OwnBookMarks bookmarks.h /^class OwnBookMarks : public QObject , public KBookmarkOwner$/;" v ln:34 -OwnBookMarks bookmarks.cpp /^OwnBookMarks::OwnBookMarks(KMainWindow *parent)$/;" f ln:30 class:OwnBookMarks -QAuthenticator webview.h /^class QAuthenticator;$/;" v ln:29 -QCompleter tabwidget.h /^class QCompleter;$/;" v ln:120 -QFileIconProvider downloadmanager.h /^class QFileIconProvider;$/;" v ln:77 -QKeyEvent cookiejar.h /^class QKeyEvent;$/;" v ln:37 -QLocalServer browserapplication.h /^class QLocalServer;$/;" v ln:35 -QMenu tabwidget.h /^class QMenu;$/;" v ln:121 -QMouseEvent webview.h /^class QMouseEvent;$/;" v ln:30 -QNetworkProxy webview.h /^class QNetworkProxy;$/;" v ln:31 -QNetworkReply webview.h /^class QNetworkReply;$/;" v ln:32 -QSortFilterProxyModel cookiejar.h /^class QSortFilterProxyModel;$/;" v ln:36 -QSslError webview.h /^class QSslError;$/;" v ln:33 -QStackedWidget tabwidget.h /^class QStackedWidget;$/;" v ln:122 -QWebFrame browsermainwindow.h /^class QWebFrame;$/;" v ln:39 -Q_DECLARE_METATYPE modelmenu.cpp /^Q_DECLARE_METATYPE(QModelIndex)$/;" f ln:120 -SEARCHBAR_H searchbar.h 22;" d ln:22 -SETTINGS_H settings.h 22;" d ln:22 -SQUEEZELABEL_H squeezelabel.h 22;" d ln:22 -SearchBar searchbar.h /^class SearchBar : public QWidget$/;" c ln:31 -SearchBar searchbar.cpp /^SearchBar::SearchBar(QWidget *parent) : $/;" f ln:27 class:SearchBar -SearchBar searchbar.cpp /^SearchBar::~SearchBar()$/;" f ln:41 class:SearchBar -Settings settings.h /^class SettingsDialog : public KDialog, private Ui::Settings$/;" c ln:33 class:Ui -SettingsDialog settings.h /^class SettingsDialog : public KDialog, private Ui::Settings$/;" v ln:33 -SettingsDialog settings.cpp /^SettingsDialog::SettingsDialog(QWidget *parent)$/;" f ln:41 class:SettingsDialog -SqueezeLabel squeezelabel.h /^class SqueezeLabel : public QLabel$/;" c ln:26 -SqueezeLabel squeezelabel.cpp /^SqueezeLabel::SqueezeLabel(QWidget *parent) : QLabel(parent)$/;" f ln:23 class:SqueezeLabel -TABWIDGET_H tabwidget.h 24;" d ln:24 -TabBar tabwidget.h /^class TabBar : public KTabBar$/;" c ln:33 -TabBar tabwidget.cpp /^TabBar::TabBar(QWidget *parent)$/;" f ln:36 class:TabBar -TabWidget browsermainwindow.h /^class TabWidget;$/;" v ln:40 -TabWidget tabwidget.h /^class TabWidget : public QTabWidget$/;" c ln:130 -TabWidget tabwidget.cpp /^TabWidget::TabWidget(QWidget *parent)$/;" f ln:196 class:TabWidget -TabWidgetMagic tabwidget.cpp /^static const qint32 TabWidgetMagic = 0xaa;$/;" v ln:768 file: -TreeProxyModel history.h /^class TreeProxyModel : public QSortFilterProxyModel$/;" c ln:326 -TreeProxyModel history.cpp /^TreeProxyModel::TreeProxyModel(QObject *parent) : QSortFilterProxyModel(parent)$/;" f ln:681 class:TreeProxyModel -URLBAR_H urlbar.h 21;" d ln:21 -Ui_CookiesDialog cookiejar.h /^class CookiesDialog : public QDialog, public Ui_CookiesDialog$/;" c ln:144 -Ui_CookiesExceptionsDialog cookiejar.h /^class CookiesExceptionsDialog : public QDialog, public Ui_CookiesExceptionsDialog$/;" c ln:186 -Ui_DownloadDialog downloadmanager.h /^class DownloadManager : public QDialog, public Ui_DownloadDialog$/;" c ln:80 -Ui_DownloadItem downloadmanager.h /^class DownloadItem : public QWidget, public Ui_DownloadItem$/;" c ln:33 -Ui_HistoryDialog history.h /^class HistoryDialog : public QDialog, public Ui_HistoryDialog$/;" c ln:342 -UrlBar urlbar.h /^class UrlBar : public QWidget$/;" c ln:35 -UrlBar urlbar.cpp /^UrlBar::UrlBar(QWidget *parent)$/;" f ln:30 class:UrlBar -UrlBar urlbar.cpp /^UrlBar::~UrlBar()$/;" f ln:55 class:UrlBar -WEBVIEW_H webview.h 22;" d ln:22 -WebActionMapper tabwidget.h /^class WebActionMapper : public QObject$/;" c ln:86 -WebActionMapper tabwidget.cpp /^WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent)$/;" f ln:834 class:WebActionMapper -WebPage webview.h /^class WebPage : public QWebPage $/;" c ln:39 -WebPage webview.cpp /^WebPage::WebPage(QObject *parent)$/;" f ln:42 class:WebPage -WebView browsermainwindow.h /^class WebView;$/;" v ln:41 -WebView tabwidget.h /^class WebView;$/;" v ln:78 -WebView webview.h /^class WebView : public QWebView $/;" c ln:70 -WebView webview.cpp /^WebView::WebView(QWidget* parent)$/;" f ln:171 class:WebView -aboutToShowRecentTabsMenu tabwidget.cpp /^void TabWidget::aboutToShowRecentTabsMenu()$/;" f ln:678 class:TabWidget -aboutToShowRecentTriggeredAction tabwidget.cpp /^void TabWidget::aboutToShowRecentTriggeredAction(QAction *action)$/;" f ln:693 class:TabWidget -acceptNavigationRequest webview.cpp /^bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type)$/;" f ln:65 class:WebPage -acceptPolicy cookiejar.cpp /^CookieJar::AcceptPolicy CookieJar::acceptPolicy() const$/;" f ln:301 class:CookieJar -activated history.cpp /^void HistoryMenu::activated(const QModelIndex &index)$/;" f ln:623 class:HistoryMenu -activeDownloads downloadmanager.cpp /^int DownloadManager::activeDownloads() const$/;" f ln:334 class:DownloadManager -addChild tabwidget.cpp /^void WebActionMapper::addChild(KAction *action)$/;" f ln:860 class:WebActionMapper -addHistoryEntry history.cpp /^void HistoryManager::addHistoryEntry(const QString &url)$/;" f ln:83 class:HistoryManager -addHistoryItem history.cpp /^void HistoryManager::addHistoryItem(const HistoryItem &item)$/;" f ln:161 class:HistoryManager -addItem downloadmanager.cpp /^void DownloadManager::addItem(DownloadItem *item)$/;" f ln:366 class:DownloadManager -addWebAction tabwidget.cpp /^void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction)$/;" f ln:319 class:TabWidget -allow cookiejar.cpp /^void CookiesExceptionsDialog::allow()$/;" f ln:766 class:CookiesExceptionsDialog -allowForSession cookiejar.cpp /^void CookiesExceptionsDialog::allowForSession()$/;" f ln:775 class:CookiesExceptionsDialog -allowForSessionCookies cookiejar.cpp /^QStringList CookieJar::allowForSessionCookies() const$/;" f ln:361 class:CookieJar -allowedCookies cookiejar.cpp /^QStringList CookieJar::allowedCookies() const$/;" f ln:352 class:CookieJar -authenticationRequired networkaccessmanager.cpp /^void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth)$/;" f ln:84 class:NetworkAccessManager -block cookiejar.cpp /^void CookiesExceptionsDialog::block()$/;" f ln:757 class:CookiesExceptionsDialog -blockedCookies cookiejar.cpp /^QStringList CookieJar::blockedCookies() const$/;" f ln:343 class:CookieJar -bumpedRows history.cpp /^int HistoryMenuModel::bumpedRows() const$/;" f ln:506 class:HistoryMenuModel -canRestoreSession browserapplication.cpp /^bool BrowserApplication::canRestoreSession() const$/;" f ln:227 class:BrowserApplication -changeOccurred autosaver.cpp /^void AutoSaver::changeOccurred()$/;" f ln:42 class:AutoSaver -checkForExpired history.cpp /^void HistoryManager::checkForExpired()$/;" f ln:131 class:HistoryManager -childChanged tabwidget.cpp /^void WebActionMapper::childChanged()$/;" f ln:883 class:WebActionMapper -chooseFixedFont settings.cpp /^void SettingsDialog::chooseFixedFont()$/;" f ln:293 class:SettingsDialog -chooseFont settings.cpp /^void SettingsDialog::chooseFont()$/;" f ln:281 class:SettingsDialog -clean browserapplication.cpp /^void BrowserApplication::clean()$/;" f ln:189 class:BrowserApplication -cleanup downloadmanager.cpp /^void DownloadManager::cleanup()$/;" f ln:487 class:DownloadManager -clear cookiejar.cpp /^void CookieJar::clear()$/;" f ln:94 class:CookieJar -clear findbar.cpp /^void FindBar::clear()$/;" f ln:71 class:FindBar -clear history.cpp /^void HistoryManager::clear()$/;" f ln:208 class:HistoryManager -clear tabwidget.cpp /^void TabWidget::clear()$/;" f ln:274 class:TabWidget -cloneTab tabwidget.cpp /^void TabBar::cloneTab()$/;" f ln:100 class:TabBar -cloneTab tabwidget.cpp /^void TabWidget::cloneTab(int index)$/;" f ln:576 class:TabWidget -closeEvent browsermainwindow.cpp /^void BrowserMainWindow::closeEvent(QCloseEvent *event)$/;" f ln:655 class:BrowserMainWindow -closeOtherTabs tabwidget.cpp /^void TabBar::closeOtherTabs()$/;" f ln:120 class:TabBar -closeOtherTabs tabwidget.cpp /^void TabWidget::closeOtherTabs(int index)$/;" f ln:564 class:TabWidget -closeTab tabwidget.cpp /^void TabBar::closeTab()$/;" f ln:110 class:TabBar -closeTab tabwidget.cpp /^void TabWidget::closeTab(int index)$/;" f ln:588 class:TabWidget -closeTabAction tabwidget.cpp /^KAction *TabWidget::closeTabAction() const$/;" f ln:375 class:TabWidget -columnCount cookiejar.cpp /^int CookieModel::columnCount(const QModelIndex &parent) const$/;" f ln:487 class:CookieModel -columnCount cookiejar.cpp /^int CookieExceptionsModel::columnCount(const QModelIndex &parent) const$/;" f ln:651 class:CookieExceptionsModel -columnCount history.cpp /^int HistoryModel::columnCount(const QModelIndex &parent) const$/;" f ln:462 class:HistoryModel -columnCount history.cpp /^int HistoryMenuModel::columnCount(const QModelIndex &parent) const$/;" f ln:514 class:HistoryMenuModel -columnCount history.cpp /^int HistoryFilterModel::columnCount(const QModelIndex &parent) const$/;" f ln:845 class:HistoryFilterModel -columnCount history.cpp /^int HistoryCompletionModel::columnCount(const QModelIndex &parent) const$/;" f ln:1014 class:HistoryCompletionModel -columnCount history.cpp /^int HistoryTreeModel::columnCount(const QModelIndex &parent) const$/;" f ln:1127 class:HistoryTreeModel -contextMenuEvent tabwidget.cpp /^void TabWidget::contextMenuEvent(QContextMenuEvent *event)$/;" f ln:713 class:TabWidget -contextMenuEvent webview.cpp /^void WebView::contextMenuEvent(QContextMenuEvent *event)$/;" f ln:187 class:WebView -contextMenuRequested tabwidget.cpp /^void TabBar::contextMenuRequested(const QPoint &position)$/;" f ln:68 class:TabBar -cookieJar browserapplication.cpp /^CookieJar *BrowserApplication::cookieJar()$/;" f ln:328 class:BrowserApplication -cookiesChanged cookiejar.cpp /^void CookieModel::cookiesChanged()$/;" f ln:512 class:CookieModel -cookiesForUrl cookiejar.cpp /^QList CookieJar::cookiesForUrl(const QUrl &url) const$/;" f ln:221 class:CookieJar -copy history.cpp /^void HistoryDialog::copy()$/;" f ln:753 class:HistoryDialog -createMenu modelmenu.cpp /^void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu, QMenu *menu)$/;" f ln:145 class:ModelMenu -createWindow webview.cpp /^QWebPage *WebPage::createWindow(QWebPage::WebWindowType type)$/;" f ln:103 class:WebPage -currentChanged tabwidget.cpp /^void TabWidget::currentChanged(int index)$/;" f ln:327 class:TabWidget -currentDestroyed tabwidget.cpp /^void WebActionMapper::currentDestroyed()$/;" f ln:854 class:WebActionMapper -currentLineEdit tabwidget.cpp /^KLineEdit *TabWidget::currentLineEdit() const$/;" f ln:405 class:TabWidget -currentTab browsermainwindow.cpp /^WebView *BrowserMainWindow::currentTab() const$/;" f ln:852 class:BrowserMainWindow -currentTitle bookmarks.cpp /^QString OwnBookMarks::currentTitle() const$/;" f ln:51 class:OwnBookMarks -currentUrl bookmarks.cpp /^QString OwnBookMarks::currentUrl() const$/;" f ln:44 class:OwnBookMarks -currentWebView tabwidget.cpp /^WebView *TabWidget::currentWebView() const$/;" f ln:411 class:TabWidget -customContextMenuRequested history.cpp /^void HistoryDialog::customContextMenuRequested(const QPoint &pos)$/;" f ln:729 class:HistoryDialog -data cookiejar.cpp /^QVariant CookieModel::data(const QModelIndex &index, int role) const$/;" f ln:450 class:CookieModel -data cookiejar.cpp /^QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const$/;" f ln:606 class:CookieExceptionsModel -data downloadmanager.cpp /^QVariant DownloadModel::data(const QModelIndex &index, int role) const$/;" f ln:512 class:DownloadModel -data history.cpp /^QVariant HistoryModel::data(const QModelIndex &index, int role) const$/;" f ln:420 class:HistoryModel -data history.cpp /^QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const$/;" f ln:784 class:HistoryFilterModel -data history.cpp /^QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const$/;" f ln:987 class:HistoryCompletionModel -data history.cpp /^QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const$/;" f ln:1097 class:HistoryTreeModel -dataString downloadmanager.cpp /^QString DownloadItem::dataString(int size) const$/;" f ln:266 class:DownloadItem -download downloadmanager.cpp /^void DownloadManager::download(const QNetworkRequest &request, bool requestFileName)$/;" f ln:344 class:DownloadManager -downloadManager browserapplication.cpp /^DownloadManager *BrowserApplication::downloadManager()$/;" f ln:334 class:BrowserApplication -downloadProgress downloadmanager.cpp /^void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)$/;" f ln:216 class:DownloadItem -downloadReadyRead downloadmanager.cpp /^void DownloadItem::downloadReadyRead()$/;" f ln:181 class:DownloadItem -downloadRequested webview.cpp /^void WebView::downloadRequested(const QNetworkRequest &request)$/;" f ln:299 class:WebView -downloadedSuccessfully downloadmanager.cpp /^bool DownloadItem::downloadedSuccessfully() const$/;" f ln:286 class:DownloadItem -downloading downloadmanager.cpp /^bool DownloadItem::downloading() const$/;" f ln:281 class:DownloadItem -dragEnterEvent tabwidget.cpp /^void TabBar::dragEnterEvent(QDragEnterEvent *event)$/;" f ln:158 class:TabBar -dropEvent tabwidget.cpp /^void TabBar::dropEvent(QDropEvent *event)$/;" f ln:171 class:TabBar -entryAdded history.cpp /^void HistoryModel::entryAdded()$/;" f ln:391 class:HistoryModel -entryUpdated history.cpp /^void HistoryModel::entryUpdated(int offset)$/;" f ln:398 class:HistoryModel -error downloadmanager.cpp /^void DownloadItem::error(QNetworkReply::NetworkError)$/;" f ln:203 class:DownloadItem -filterAcceptsRow history.cpp /^bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const$/;" f ln:688 class:TreeProxyModel -finished downloadmanager.cpp /^void DownloadItem::finished()$/;" f ln:291 class:DownloadItem -firstSeparator modelmenu.cpp /^int ModelMenu::firstSeparator() const$/;" f ln:78 class:ModelMenu -flags history.cpp /^Qt::ItemFlags HistoryTreeModel::flags(const QModelIndex &index) const$/;" f ln:1226 class:HistoryTreeModel -generateGradient urlbar.cpp /^QLinearGradient UrlBar::generateGradient(const QColor &color) const$/;" f ln:97 class:UrlBar -geometryChangeRequested browsermainwindow.cpp /^void BrowserMainWindow::geometryChangeRequested(const QRect &geometry)$/;" f ln:977 class:BrowserMainWindow -getFileName downloadmanager.cpp /^void DownloadItem::getFileName()$/;" f ln:93 class:DownloadItem -guessUrlFromString browsermainwindow.cpp /^KUrl BrowserMainWindow::guessUrlFromString(const QString &string)$/;" f ln:443 class:BrowserMainWindow -handleUnsupportedContent downloadmanager.cpp /^void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool requestFileName)$/;" f ln:351 class:DownloadManager -handleUnsupportedContent webview.cpp /^void WebPage::handleUnsupportedContent(QNetworkReply *reply)$/;" f ln:119 class:WebPage -hasChildren history.cpp /^bool HistoryTreeModel::hasChildren(const QModelIndex &parent) const$/;" f ln:1217 class:HistoryTreeModel -headerData cookiejar.cpp /^QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:415 class:CookieModel -headerData cookiejar.cpp /^QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:583 class:CookieExceptionsModel -headerData history.cpp /^QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:405 class:HistoryModel -headerData history.cpp /^QVariant HistoryFilterModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:823 class:HistoryFilterModel -headerData history.cpp /^QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation, int role) const$/;" f ln:1091 class:HistoryTreeModel -history history.cpp /^QList HistoryManager::history() const$/;" f ln:71 class:HistoryManager -historyContains history.cpp /^bool HistoryManager::historyContains(const QString &url) const$/;" f ln:77 class:HistoryManager -historyFilterModel history.cpp /^HistoryFilterModel *HistoryManager::historyFilterModel() const$/;" f ln:119 class:HistoryManager -historyLimit history.cpp /^int HistoryManager::historyLimit() const$/;" f ln:192 class:HistoryManager -historyLocation history.cpp /^int HistoryFilterModel::historyLocation(const QString &url) const$/;" f ln:775 class:HistoryFilterModel -historyManager browserapplication.cpp /^HistoryManager *BrowserApplication::historyManager()$/;" f ln:357 class:BrowserApplication -historyModel history.cpp /^HistoryModel *HistoryManager::historyModel() const$/;" f ln:113 class:HistoryManager -historyReset history.cpp /^void HistoryModel::historyReset()$/;" f ln:385 class:HistoryModel -historyTreeModel history.cpp /^HistoryTreeModel *HistoryManager::historyTreeModel() const$/;" f ln:125 class:HistoryManager -hoverRole modelmenu.cpp /^int ModelMenu::hoverRole() const$/;" f ln:102 class:ModelMenu -hovered modelmenu.cpp /^void ModelMenu::hovered(QAction *action)$/;" f ln:213 class:ModelMenu -icon browserapplication.cpp /^KIcon BrowserApplication::icon(const KUrl &url) const$/;" f ln:370 class:BrowserApplication -index history.cpp /^QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:572 class:HistoryMenuModel -index history.cpp /^QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:886 class:HistoryFilterModel -index history.cpp /^QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:1036 class:HistoryCompletionModel -index history.cpp /^QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const$/;" f ln:1195 class:HistoryTreeModel -init downloadmanager.cpp /^void DownloadItem::init()$/;" f ln:65 class:DownloadItem -instance browserapplication.cpp /^BrowserApplication *BrowserApplication::instance()$/;" f ln:110 class:BrowserApplication -isTheOnlyBrowser browserapplication.cpp /^bool BrowserApplication::isTheOnlyBrowser() const$/;" f ln:266 class:BrowserApplication -keepPolicy cookiejar.cpp /^CookieJar::KeepPolicy CookieJar::keepPolicy() const$/;" f ln:322 class:CookieJar -keyPressEvent edittableview.cpp /^void EditTableView::keyPressEvent(QKeyEvent *event)$/;" f ln:29 class:EditTableView -keyPressEvent edittreeview.cpp /^void EditTreeView::keyPressEvent(QKeyEvent *event)$/;" f ln:30 class:EditTreeView -keyPressEvent findbar.cpp /^void FindBar::keyPressEvent(QKeyEvent* event)$/;" f ln:88 class:FindBar -lastStatusBarText webview.cpp /^QString WebView::lastStatusBarText() const$/;" f ln:254 class:WebView -lineEdit findbar.cpp /^KLineEdit *FindBar::lineEdit()$/;" f ln:65 class:FindBar -lineEdit searchbar.cpp /^KLineEdit *SearchBar::lineEdit()$/;" f ln:58 class:SearchBar -lineEdit tabwidget.cpp /^KLineEdit *TabWidget::lineEdit(int index) const$/;" f ln:417 class:TabWidget -lineEdit urlbar.cpp /^KLineEdit *UrlBar::lineEdit()$/;" f ln:63 class:UrlBar -lineEditReturnPressed tabwidget.cpp /^void TabWidget::lineEditReturnPressed()$/;" f ln:538 class:TabWidget -lineEditStack tabwidget.cpp /^QWidget *TabWidget::lineEditStack() const$/;" f ln:399 class:TabWidget -load cookiejar.cpp /^void CookieJar::load()$/;" f ln:101 class:CookieJar -load downloadmanager.cpp /^void DownloadManager::load()$/;" f ln:451 class:DownloadManager -load history.cpp /^void HistoryManager::load()$/;" f ln:228 class:HistoryManager -load history.cpp /^void HistoryFilterModel::load() const$/;" f ln:903 class:HistoryFilterModel -loadDefaultState browsermainwindow.cpp /^void BrowserMainWindow::loadDefaultState()$/;" f ln:119 class:BrowserMainWindow -loadDefaults settings.cpp /^void SettingsDialog::loadDefaults()$/;" f ln:70 class:SettingsDialog -loadFinished webview.cpp /^void WebView::loadFinished()$/;" f ln:236 class:WebView -loadFromSettings settings.cpp /^void SettingsDialog::loadFromSettings()$/;" f ln:90 class:SettingsDialog -loadPage browsermainwindow.cpp /^void BrowserMainWindow::loadPage(const QString &page)$/;" f ln:832 class:BrowserMainWindow -loadSettings browserapplication.cpp /^void BrowserApplication::loadSettings()$/;" f ln:146 class:BrowserApplication -loadSettings cookiejar.cpp /^void CookieJar::loadSettings()$/;" f ln:133 class:CookieJar -loadSettings history.cpp /^void HistoryManager::loadSettings()$/;" f ln:218 class:HistoryManager -loadSettings networkaccessmanager.cpp /^void NetworkAccessManager::loadSettings()$/;" f ln:58 class:NetworkAccessManager -loadUrl browsermainwindow.cpp /^void BrowserMainWindow::loadUrl(const KUrl &url)$/;" f ln:500 class:BrowserMainWindow -loadUrl webview.cpp /^void WebView::loadUrl(const KUrl &url)$/;" f ln:247 class:WebView -loadUrlInCurrentTab tabwidget.cpp /^void TabWidget::loadUrlInCurrentTab(const KUrl &url)$/;" f ln:739 class:TabWidget -main main.cpp /^int main(int argc, char **argv)$/;" f ln:29 -mainWindow browserapplication.cpp /^BrowserMainWindow *BrowserApplication::mainWindow()$/;" f ln:288 class:BrowserApplication -mainWindow webview.cpp /^BrowserMainWindow *WebPage::mainWindow()$/;" f ln:53 class:WebPage -mainWindows browserapplication.cpp /^QList BrowserApplication::mainWindows()$/;" f ln:175 class:BrowserApplication -makeAction modelmenu.cpp /^KAction *ModelMenu::makeAction(const QModelIndex &index)$/;" f ln:184 class:ModelMenu -makeAction modelmenu.cpp /^KAction *ModelMenu::makeAction(const KIcon &icon, const QString &text, QObject *parent)$/;" f ln:194 class:ModelMenu -mapFromSource history.cpp /^QModelIndex HistoryMenuModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:545 class:HistoryMenuModel -mapFromSource history.cpp /^QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:859 class:HistoryFilterModel -mapFromSource history.cpp /^QModelIndex HistoryCompletionModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:1020 class:HistoryCompletionModel -mapFromSource history.cpp /^QModelIndex HistoryTreeModel::mapFromSource(const QModelIndex &sourceIndex) const$/;" f ln:1312 class:HistoryTreeModel -mapToSource history.cpp /^QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:553 class:HistoryMenuModel -mapToSource history.cpp /^QModelIndex HistoryFilterModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:851 class:HistoryFilterModel -mapToSource history.cpp /^QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:1027 class:HistoryCompletionModel -mapToSource history.cpp /^QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const$/;" f ln:1185 class:HistoryTreeModel -maxRows modelmenu.cpp /^int ModelMenu::maxRows() const$/;" f ln:66 class:ModelMenu -metaDataChanged downloadmanager.cpp /^void DownloadItem::metaDataChanged()$/;" f ln:211 class:DownloadItem -model modelmenu.cpp /^QAbstractItemModel *ModelMenu::model() const$/;" f ln:54 class:ModelMenu -mouseDoubleClickEvent tabwidget.cpp /^void TabWidget::mouseDoubleClickEvent(QMouseEvent *event)$/;" f ln:700 class:TabWidget -mouseMoveEvent tabwidget.cpp /^void TabBar::mouseMoveEvent(QMouseEvent *event)$/;" f ln:138 class:TabBar -mousePressEvent tabwidget.cpp /^void TabBar::mousePressEvent(QMouseEvent *event)$/;" f ln:130 class:TabBar -mousePressEvent webview.cpp /^void WebView::mousePressEvent(QMouseEvent *event)$/;" f ln:271 class:WebView -mouseReleaseEvent tabwidget.cpp /^void TabWidget::mouseReleaseEvent(QMouseEvent *event)$/;" f ln:723 class:TabWidget -mouseReleaseEvent webview.cpp /^void WebView::mouseReleaseEvent(QMouseEvent *event)$/;" f ln:279 class:WebView -moveTab tabwidget.cpp /^void TabWidget::moveTab(int fromIndex, int toIndex)$/;" f ln:287 class:TabWidget -networkAccessManager browserapplication.cpp /^NetworkAccessManager *BrowserApplication::networkAccessManager()$/;" f ln:345 class:BrowserApplication -newLocalSocketConnection browserapplication.cpp /^void BrowserApplication::newLocalSocketConnection()$/;" f ln:297 class:BrowserApplication -newMainWindow browserapplication.cpp /^BrowserMainWindow *BrowserApplication::newMainWindow()$/;" f ln:279 class:BrowserApplication -newTab tabwidget.cpp /^WebView *TabWidget::newTab(bool makeCurrent)$/;" f ln:457 class:TabWidget -newTabAction tabwidget.cpp /^KAction *TabWidget::newTabAction() const$/;" f ln:369 class:TabWidget -nextTab tabwidget.cpp /^void TabWidget::nextTab()$/;" f ln:750 class:TabWidget -nextTabAction tabwidget.cpp /^KAction *TabWidget::nextTabAction() const$/;" f ln:387 class:TabWidget -open downloadmanager.cpp /^void DownloadItem::open()$/;" f ln:153 class:DownloadItem -open history.cpp /^void HistoryDialog::open()$/;" f ln:744 class:HistoryDialog -openBookmark bookmarks.cpp /^void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons , Qt::KeyboardModifiers )$/;" f ln:39 class:OwnBookMarks -openLinkInNewTab webview.cpp /^void WebView::openLinkInNewTab()$/;" f ln:223 class:WebView -openUrl browserapplication.cpp /^void BrowserApplication::openUrl(const KUrl &url)$/;" f ln:272 class:BrowserApplication -operator<< cookiejar.cpp /^QDataStream &operator<<(QDataStream &stream, const QList &list)$/;" f ln:40 -operator>> cookiejar.cpp /^QDataStream &operator>>(QDataStream &stream, QList &list)$/;" f ln:49 -paintEvent squeezelabel.cpp /^void SqueezeLabel::paintEvent(QPaintEvent *event)$/;" f ln:27 class:SqueezeLabel -parent history.cpp /^QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const$/;" f ln:594 class:HistoryMenuModel -parent history.cpp /^QModelIndex HistoryFilterModel::parent(const QModelIndex &) const$/;" f ln:897 class:HistoryFilterModel -parent history.cpp /^QModelIndex HistoryCompletionModel::parent(const QModelIndex &) const$/;" f ln:1045 class:HistoryCompletionModel -parent history.cpp /^QModelIndex HistoryTreeModel::parent(const QModelIndex &index) const$/;" f ln:1208 class:HistoryTreeModel -postLaunch browserapplication.cpp /^void BrowserApplication::postLaunch()$/;" f ln:119 class:BrowserApplication -postPopulated history.cpp /^void HistoryMenu::postPopulated()$/;" f ln:648 class:HistoryMenu -postPopulated modelmenu.cpp /^void ModelMenu::postPopulated()$/;" f ln:43 class:ModelMenu -prePopulated history.cpp /^bool HistoryMenu::prePopulated()$/;" f ln:629 class:HistoryMenu -prePopulated modelmenu.cpp /^bool ModelMenu::prePopulated()$/;" f ln:37 class:ModelMenu -previousTab tabwidget.cpp /^void TabWidget::previousTab()$/;" f ln:759 class:TabWidget -previousTabAction tabwidget.cpp /^KAction *TabWidget::previousTabAction() const$/;" f ln:393 class:TabWidget -printRequested browsermainwindow.cpp /^void BrowserMainWindow::printRequested(QWebFrame *frame)$/;" f ln:603 class:BrowserMainWindow -proxyAuthenticationRequired networkaccessmanager.cpp /^void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)$/;" f ln:108 class:NetworkAccessManager -purgeOldCookies cookiejar.cpp /^void CookieJar::purgeOldCookies()$/;" f ln:203 class:CookieJar -recentlyClosedTabsAction tabwidget.cpp /^KAction *TabWidget::recentlyClosedTabsAction() const$/;" f ln:381 class:TabWidget -reloadAllTabs tabwidget.cpp /^void TabWidget::reloadAllTabs()$/;" f ln:525 class:TabWidget -reloadTab tabwidget.cpp /^void TabBar::reloadTab()$/;" f ln:184 class:TabBar -reloadTab tabwidget.cpp /^void TabWidget::reloadTab(int index)$/;" f ln:305 class:TabWidget -removeAll edittableview.cpp /^void EditTableView::removeAll()$/;" f ln:52 class:EditTableView -removeAll edittreeview.cpp /^void EditTreeView::removeAll()$/;" f ln:50 class:EditTreeView -removeOne edittableview.cpp /^void EditTableView::removeOne()$/;" f ln:40 class:EditTableView -removeOne edittreeview.cpp /^void EditTreeView::removeOne()$/;" f ln:41 class:EditTreeView -removePolicy downloadmanager.cpp /^DownloadManager::RemovePolicy DownloadManager::removePolicy() const$/;" f ln:412 class:DownloadManager -removeRows cookiejar.cpp /^bool CookieModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:497 class:CookieModel -removeRows cookiejar.cpp /^bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:661 class:CookieExceptionsModel -removeRows downloadmanager.cpp /^bool DownloadModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:527 class:DownloadModel -removeRows history.cpp /^bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:474 class:HistoryModel -removeRows history.cpp /^bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:959 class:HistoryFilterModel -removeRows history.cpp /^bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent)$/;" f ln:1234 class:HistoryTreeModel -restoreLastSession browserapplication.cpp /^void BrowserApplication::restoreLastSession()$/;" f ln:233 class:BrowserApplication -restoreState browsermainwindow.cpp /^bool BrowserMainWindow::restoreState(const QByteArray &state)$/;" f ln:174 class:BrowserMainWindow -restoreState tabwidget.cpp /^bool TabWidget::restoreState(const QByteArray &state)$/;" f ln:798 class:TabWidget -rootDestroyed tabwidget.cpp /^void WebActionMapper::rootDestroyed()$/;" f ln:848 class:WebActionMapper -rootIndex modelmenu.cpp /^QModelIndex ModelMenu::rootIndex() const$/;" f ln:90 class:ModelMenu -rootTriggered tabwidget.cpp /^void WebActionMapper::rootTriggered()$/;" f ln:873 class:WebActionMapper -rowCount cookiejar.cpp /^int CookieModel::rowCount(const QModelIndex &parent) const$/;" f ln:492 class:CookieModel -rowCount cookiejar.cpp /^int CookieExceptionsModel::rowCount(const QModelIndex &parent) const$/;" f ln:656 class:CookieExceptionsModel -rowCount downloadmanager.cpp /^int DownloadModel::rowCount(const QModelIndex &parent) const$/;" f ln:522 class:DownloadModel -rowCount history.cpp /^int HistoryModel::rowCount(const QModelIndex &parent) const$/;" f ln:468 class:HistoryModel -rowCount history.cpp /^int HistoryMenuModel::rowCount(const QModelIndex &parent) const$/;" f ln:519 class:HistoryMenuModel -rowCount history.cpp /^int HistoryFilterModel::rowCount(const QModelIndex &parent) const$/;" f ln:836 class:HistoryFilterModel -rowCount history.cpp /^int HistoryCompletionModel::rowCount(const QModelIndex &parent) const$/;" f ln:1008 class:HistoryCompletionModel -rowCount history.cpp /^int HistoryTreeModel::rowCount(const QModelIndex &parent) const$/;" f ln:1133 class:HistoryTreeModel -s_downloadManager browserapplication.cpp /^DownloadManager *BrowserApplication::s_downloadManager = 0;$/;" v ln:52 class:BrowserApplication -s_historyManager browserapplication.cpp /^HistoryManager *BrowserApplication::s_historyManager = 0;$/;" v ln:53 class:BrowserApplication -s_networkAccessManager browserapplication.cpp /^NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0;$/;" v ln:54 class:BrowserApplication -save browsermainwindow.cpp /^void BrowserMainWindow::save()$/;" f ln:138 class:BrowserMainWindow -save cookiejar.cpp /^void CookieJar::save()$/;" f ln:156 class:CookieJar -save downloadmanager.cpp /^void DownloadManager::save() const$/;" f ln:425 class:DownloadManager -save history.cpp /^void HistoryManager::save()$/;" f ln:296 class:HistoryManager -saveFileName downloadmanager.cpp /^QString DownloadItem::saveFileName(const QString &directory) const$/;" f ln:118 class:DownloadItem -saveIfNeccessary autosaver.cpp /^void AutoSaver::saveIfNeccessary()$/;" f ln:63 class:AutoSaver -saveSession browserapplication.cpp /^void BrowserApplication::saveSession()$/;" f ln:202 class:BrowserApplication -saveState browsermainwindow.cpp /^QByteArray BrowserMainWindow::saveState(bool withTabs) const$/;" f ln:154 class:BrowserMainWindow -saveState tabwidget.cpp /^QByteArray TabWidget::saveState() const$/;" f ln:771 class:TabWidget -saveToSettings settings.cpp /^void SettingsDialog::saveToSettings()$/;" f ln:182 class:SettingsDialog -searchNow searchbar.cpp /^void SearchBar::searchNow()$/;" f ln:45 class:SearchBar -selectTabAction tabwidget.cpp /^void TabBar::selectTabAction()$/;" f ln:56 class:TabBar -separatorRole modelmenu.cpp /^int ModelMenu::separatorRole() const$/;" f ln:114 class:ModelMenu -setAcceptPolicy cookiejar.cpp /^void CookieJar::setAcceptPolicy(AcceptPolicy policy)$/;" f ln:310 class:CookieJar -setAllowForSessionCookies cookiejar.cpp /^void CookieJar::setAllowForSessionCookies(const QStringList &list)$/;" f ln:392 class:CookieJar -setAllowedCookies cookiejar.cpp /^void CookieJar::setAllowedCookies(const QStringList &list)$/;" f ln:381 class:CookieJar -setBlockedCookies cookiejar.cpp /^void CookieJar::setBlockedCookies(const QStringList &list)$/;" f ln:370 class:CookieJar -setCookiesFromUrl cookiejar.cpp /^bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url)$/;" f ln:237 class:CookieJar -setFirstSeparator modelmenu.cpp /^void ModelMenu::setFirstSeparator(int offset)$/;" f ln:72 class:ModelMenu -setHistory history.cpp /^void HistoryManager::setHistory(const QList &history, bool loadedAndSorted)$/;" f ln:93 class:HistoryManager -setHistoryLimit history.cpp /^void HistoryManager::setHistoryLimit(int limit)$/;" f ln:198 class:HistoryManager -setHomeToCurrentPage settings.cpp /^void SettingsDialog::setHomeToCurrentPage()$/;" f ln:306 class:SettingsDialog -setHoverRole modelmenu.cpp /^void ModelMenu::setHoverRole(int role)$/;" f ln:96 class:ModelMenu -setInitialActions history.cpp /^void HistoryMenu::setInitialActions(QList actions)$/;" f ln:671 class:HistoryMenu -setKeepPolicy cookiejar.cpp /^void CookieJar::setKeepPolicy(KeepPolicy policy)$/;" f ln:331 class:CookieJar -setMaxRows modelmenu.cpp /^void ModelMenu::setMaxRows(int max)$/;" f ln:60 class:ModelMenu -setModel modelmenu.cpp /^void ModelMenu::setModel(QAbstractItemModel *model)$/;" f ln:48 class:ModelMenu -setProgress webview.cpp /^void WebView::setProgress(int progress)$/;" f ln:230 class:WebView -setRemovePolicy downloadmanager.cpp /^void DownloadManager::setRemovePolicy(RemovePolicy policy)$/;" f ln:417 class:DownloadManager -setRootIndex modelmenu.cpp /^void ModelMenu::setRootIndex(const QModelIndex &index)$/;" f ln:84 class:ModelMenu -setSeparatorRole modelmenu.cpp /^void ModelMenu::setSeparatorRole(int role)$/;" f ln:108 class:ModelMenu -setSourceModel history.cpp /^void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel)$/;" f ln:790 class:HistoryFilterModel -setSourceModel history.cpp /^void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel)$/;" f ln:1051 class:HistoryCompletionModel -setSourceModel history.cpp /^void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel)$/;" f ln:1256 class:HistoryTreeModel -setStatusBarText webview.cpp /^void WebView::setStatusBarText(const QString &string)$/;" f ln:293 class:WebView -setWebView urlbar.cpp /^void UrlBar::setWebView(WebView *webView)$/;" f ln:69 class:UrlBar -setupMenu browsermainwindow.cpp /^void BrowserMainWindow::setupMenu()$/;" f ln:214 class:BrowserMainWindow -setupToolBar browsermainwindow.cpp /^void BrowserMainWindow::setupToolBar()$/;" f ln:373 class:BrowserMainWindow -showCookies settings.cpp /^void SettingsDialog::showCookies()$/;" f ln:267 class:SettingsDialog -showExceptions settings.cpp /^void SettingsDialog::showExceptions()$/;" f ln:274 class:SettingsDialog -showFindBar findbar.cpp /^void FindBar::showFindBar()$/;" f ln:77 class:FindBar -showHistoryDialog history.cpp /^void HistoryMenu::showHistoryDialog()$/;" f ln:663 class:HistoryMenu -sizeHint browsermainwindow.cpp /^QSize BrowserMainWindow::sizeHint() const$/;" f ln:129 class:BrowserMainWindow -slotAboutToShowBackMenu browsermainwindow.cpp /^void BrowserMainWindow::slotAboutToShowBackMenu()$/;" f ln:881 class:BrowserMainWindow -slotAboutToShowWindowMenu browsermainwindow.cpp /^void BrowserMainWindow::slotAboutToShowWindowMenu()$/;" f ln:902 class:BrowserMainWindow -slotAddBookmark browsermainwindow.cpp /^void BrowserMainWindow::slotAddBookmark()$/;" f ln:410 class:BrowserMainWindow -slotApply settings.cpp /^void SettingsDialog::slotApply()$/;" f ln:323 class:SettingsDialog -slotDownloadManager browsermainwindow.cpp /^void BrowserMainWindow::slotDownloadManager()$/;" f ln:508 class:BrowserMainWindow -slotFileNew browsermainwindow.cpp /^void BrowserMainWindow::slotFileNew()$/;" f ln:559 class:BrowserMainWindow -slotFileOpen browsermainwindow.cpp /^void BrowserMainWindow::slotFileOpen()$/;" f ln:569 class:BrowserMainWindow -slotFilePrint browsermainwindow.cpp /^void BrowserMainWindow::slotFilePrint()$/;" f ln:594 class:BrowserMainWindow -slotFilePrintPreview browsermainwindow.cpp /^void BrowserMainWindow::slotFilePrintPreview()$/;" f ln:583 class:BrowserMainWindow -slotFileSaveAs browsermainwindow.cpp /^void BrowserMainWindow::slotFileSaveAs()$/;" f ln:523 class:BrowserMainWindow -slotFind browsermainwindow.cpp /^void BrowserMainWindow::slotFind(const QString & search)$/;" f ln:675 class:BrowserMainWindow -slotFindNext browsermainwindow.cpp /^void BrowserMainWindow::slotFindNext()$/;" f ln:694 class:BrowserMainWindow -slotFindPrevious browsermainwindow.cpp /^void BrowserMainWindow::slotFindPrevious()$/;" f ln:702 class:BrowserMainWindow -slotHome browsermainwindow.cpp /^void BrowserMainWindow::slotHome()$/;" f ln:783 class:BrowserMainWindow -slotLoadProgress browsermainwindow.cpp /^void BrowserMainWindow::slotLoadProgress(int progress)$/;" f ln:858 class:BrowserMainWindow -slotOk settings.cpp /^void SettingsDialog::slotOk()$/;" f ln:317 class:SettingsDialog -slotOpenActionUrl browsermainwindow.cpp /^void BrowserMainWindow::slotOpenActionUrl(QAction *action)$/;" f ln:944 class:BrowserMainWindow -slotOpenNext browsermainwindow.cpp /^void BrowserMainWindow::slotOpenNext()$/;" f ln:970 class:BrowserMainWindow -slotOpenPrevious browsermainwindow.cpp /^void BrowserMainWindow::slotOpenPrevious()$/;" f ln:962 class:BrowserMainWindow -slotPreferences browsermainwindow.cpp /^void BrowserMainWindow::slotPreferences()$/;" f ln:531 class:BrowserMainWindow -slotPrivateBrowsing browsermainwindow.cpp /^void BrowserMainWindow::slotPrivateBrowsing()$/;" f ln:615 class:BrowserMainWindow -slotSelectLineEdit browsermainwindow.cpp /^void BrowserMainWindow::slotSelectLineEdit()$/;" f ln:515 class:BrowserMainWindow -slotShowWindow browsermainwindow.cpp /^void BrowserMainWindow::slotShowWindow()$/;" f ln:926 class:BrowserMainWindow -slotSwapFocus browsermainwindow.cpp /^void BrowserMainWindow::slotSwapFocus()$/;" f ln:822 class:BrowserMainWindow -slotToggleInspector browsermainwindow.cpp /^void BrowserMainWindow::slotToggleInspector(bool enable)$/;" f ln:803 class:BrowserMainWindow -slotUpdateStatusbar browsermainwindow.cpp /^void BrowserMainWindow::slotUpdateStatusbar(const QString &string)$/;" f ln:540 class:BrowserMainWindow -slotUpdateWindowTitle browsermainwindow.cpp /^void BrowserMainWindow::slotUpdateWindowTitle(const QString &title)$/;" f ln:548 class:BrowserMainWindow -slotViewFindBar browsermainwindow.cpp /^void BrowserMainWindow::slotViewFindBar()$/;" f ln:688 class:BrowserMainWindow -slotViewFullScreen browsermainwindow.cpp /^void BrowserMainWindow::slotViewFullScreen(bool makeFullScreen)$/;" f ln:739 class:BrowserMainWindow -slotViewPageSource browsermainwindow.cpp /^void BrowserMainWindow::slotViewPageSource()$/;" f ln:768 class:BrowserMainWindow -slotViewStatusbar browsermainwindow.cpp /^void BrowserMainWindow::slotViewStatusbar()$/;" f ln:428 class:BrowserMainWindow -slotViewTextBigger browsermainwindow.cpp /^void BrowserMainWindow::slotViewTextBigger()$/;" f ln:711 class:BrowserMainWindow -slotViewTextNormal browsermainwindow.cpp /^void BrowserMainWindow::slotViewTextNormal()$/;" f ln:720 class:BrowserMainWindow -slotViewTextSmaller browsermainwindow.cpp /^void BrowserMainWindow::slotViewTextSmaller()$/;" f ln:729 class:BrowserMainWindow -slotWebSearch browsermainwindow.cpp /^void BrowserMainWindow::slotWebSearch()$/;" f ln:794 class:BrowserMainWindow -sourceDataChanged history.cpp /^void HistoryFilterModel::sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)$/;" f ln:817 class:HistoryFilterModel -sourceDateRow history.cpp /^int HistoryTreeModel::sourceDateRow(int row) const$/;" f ln:1168 class:HistoryTreeModel -sourceReset history.cpp /^void HistoryFilterModel::sourceReset()$/;" f ln:829 class:HistoryFilterModel -sourceReset history.cpp /^void HistoryCompletionModel::sourceReset()$/;" f ln:1075 class:HistoryCompletionModel -sourceReset history.cpp /^void HistoryTreeModel::sourceReset()$/;" f ln:1282 class:HistoryTreeModel -sourceRowsInserted history.cpp /^void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start, int end)$/;" f ln:922 class:HistoryFilterModel -sourceRowsInserted history.cpp /^void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, int end)$/;" f ln:1289 class:HistoryTreeModel -sourceRowsRemoved history.cpp /^void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int end)$/;" f ln:945 class:HistoryFilterModel -sourceRowsRemoved history.cpp /^void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, int end)$/;" f ln:1330 class:HistoryTreeModel -sslErrors networkaccessmanager.cpp /^void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList &error)$/;" f ln:133 class:NetworkAccessManager -stop downloadmanager.cpp /^void DownloadItem::stop()$/;" f ln:142 class:DownloadItem -tabWidget browsermainwindow.cpp /^TabWidget *BrowserMainWindow::tabWidget() const$/;" f ln:845 class:BrowserMainWindow -textChanged cookiejar.cpp /^void CookiesExceptionsDialog::textChanged(const QString &text)$/;" f ln:749 class:CookiesExceptionsDialog -timerEvent autosaver.cpp /^void AutoSaver::timerEvent(QTimerEvent *event)$/;" f ln:54 class:AutoSaver -triggered modelmenu.cpp /^void ModelMenu::triggered(QAction *action)$/;" f ln:203 class:ModelMenu -tryAgain downloadmanager.cpp /^void DownloadItem::tryAgain()$/;" f ln:160 class:DownloadItem -updateCurrent tabwidget.cpp /^void WebActionMapper::updateCurrent(QWebPage *currentParent)$/;" f ln:898 class:WebActionMapper -updateHistoryItem history.cpp /^void HistoryManager::updateHistoryItem(const KUrl &url, const QString &title)$/;" f ln:175 class:HistoryManager -updateInfoLabel downloadmanager.cpp /^void DownloadItem::updateInfoLabel()$/;" f ln:229 class:DownloadItem -updateItemCount downloadmanager.cpp /^void DownloadManager::updateItemCount()$/;" f ln:500 class:DownloadManager -updateRow downloadmanager.cpp /^void DownloadManager::updateRow()$/;" f ln:382 class:DownloadManager -updateStatusbarActionText browsermainwindow.cpp /^void BrowserMainWindow::updateStatusbarActionText(bool visible)$/;" f ln:420 class:BrowserMainWindow -url webview.cpp /^KUrl WebView::url() const$/;" f ln:260 class:WebView -webAction tabwidget.cpp /^QWebPage::WebAction WebActionMapper::webAction() const$/;" f ln:867 class:WebActionMapper -webView tabwidget.cpp /^WebView *TabWidget::webView(int index) const$/;" f ln:426 class:TabWidget -webViewIconChanged tabwidget.cpp /^void TabWidget::webViewIconChanged()$/;" f ln:642 class:TabWidget -webViewIconChanged urlbar.cpp /^void UrlBar::webViewIconChanged()$/;" f ln:88 class:UrlBar -webViewIndex tabwidget.cpp /^int TabWidget::webViewIndex(WebView *webView) const$/;" f ln:450 class:TabWidget -webViewLoadStarted tabwidget.cpp /^void TabWidget::webViewLoadStarted()$/;" f ln:631 class:TabWidget -webViewTitleChanged tabwidget.cpp /^void TabWidget::webViewTitleChanged(const QString &title)$/;" f ln:654 class:TabWidget -webViewUrlChanged tabwidget.cpp /^void TabWidget::webViewUrlChanged(const QUrl &url)$/;" f ln:667 class:TabWidget -webViewUrlChanged urlbar.cpp /^void UrlBar::webViewUrlChanged(const QUrl &url)$/;" f ln:81 class:UrlBar -wheelEvent webview.cpp /^void WebView::wheelEvent(QWheelEvent *event)$/;" f ln:209 class:WebView -windowCloseRequested tabwidget.cpp /^void TabWidget::windowCloseRequested()$/;" f ln:549 class:TabWidget diff --git a/src/urlbar.cpp b/src/urlbar.cpp index bd84b6d5..5ddb26aa 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -22,7 +22,7 @@ #include "urlbar.moc" #include "browserapplication.h" -#include "browsermainwindow.h" +#include "mainwindow.h" UrlBar::UrlBar(QWidget *parent) diff --git a/src/webview.cpp b/src/webview.cpp index edae86eb..e17a961a 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -20,7 +20,7 @@ #include "browserapplication.h" -#include "browsermainwindow.h" +#include "mainwindow.h" #include "cookiejar.h" #include "downloadmanager.h" #include "networkaccessmanager.h" @@ -48,12 +48,12 @@ WebPage::WebPage(QObject *parent) } -BrowserMainWindow *WebPage::mainWindow() +MainWindow *WebPage::mainWindow() { QObject *w = this->parent(); while (w) { - if (BrowserMainWindow *mw = qobject_cast(w)) + if (MainWindow *mw = qobject_cast(w)) return mw; w = w->parent(); } @@ -73,7 +73,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if (newWindow) { BrowserApplication::instance()->newMainWindow(); - BrowserMainWindow *newMainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *newMainWindow = BrowserApplication::instance()->mainWindow(); webView = newMainWindow->currentTab(); newMainWindow->raise(); newMainWindow->activateWindow(); @@ -108,7 +108,7 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) return mainWindow()->tabWidget()->newTab()->page(); } BrowserApplication::instance()->newMainWindow(); - BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); return mainWindow->currentTab()->page(); } diff --git a/src/webview.h b/src/webview.h index aa8efb81..6710aac4 100644 --- a/src/webview.h +++ b/src/webview.h @@ -33,7 +33,7 @@ class QNetworkReply; class QSslError; QT_END_NAMESPACE -class BrowserMainWindow; +class MainWindow; class WebPage : public QWebPage @@ -45,7 +45,7 @@ signals: public: WebPage(QObject *parent = 0); - BrowserMainWindow *mainWindow(); + MainWindow *mainWindow(); protected: bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); -- cgit v1.2.1 From 9e7f74269e25062a33af0a2603bf258cd4b228e2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 29 Dec 2008 01:52:07 +0100 Subject: Ported from KMainWindow to KXmlGuiWindow. Yeah! .. --- CMakeLists.txt | 6 +- data/rekonq.desktop | 6 +- src/CMakeLists.txt | 9 +- src/Messages.sh | 4 + src/history.cpp | 2 +- src/history.h | 7 +- src/main.cpp | 43 +++-- src/mainwindow.cpp | 481 ++++++++++++++++++---------------------------------- src/mainwindow.h | 46 ++--- src/modelmenu.cpp | 2 +- src/modelmenu.h | 3 +- src/rekonqui.rc | 77 +++++++++ src/tabwidget.cpp | 2 +- 13 files changed, 305 insertions(+), 383 deletions(-) create mode 100644 src/Messages.sh create mode 100644 src/rekonqui.rc diff --git a/CMakeLists.txt b/CMakeLists.txt index 532f39b4..51354090 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,9 +42,9 @@ MESSAGE(STATUS "") # Require shared libraries results. IF(QT_FOUND) - MESSAGE(STATUS " qt library found............... YES") + MESSAGE(STATUS " Qt library found............... YES") ELSE(QT_FOUND) - MESSAGE(STATUS " qt library found............... NO") + MESSAGE(STATUS " Qt library found............... NO") MESSAGE(STATUS "") MESSAGE(SEND_ERROR " rekonq needs at least Qt 4.4.0. Please install it and try compiling again.") MESSAGE(STATUS " Qt website is at http://www.trolltech.com") @@ -86,4 +86,4 @@ IF(REKONQ_CAN_BE_COMPILED) ENDIF(REKONQ_CAN_BE_COMPILED) -# ===================================================================================================== \ No newline at end of file +# ===================================================================================================== diff --git a/data/rekonq.desktop b/data/rekonq.desktop index 126cba2a..5a93f099 100644 --- a/data/rekonq.desktop +++ b/data/rekonq.desktop @@ -3,6 +3,8 @@ Name=rekonq GenericName=Webkit KDE Browser Icon=rekonq Type=Application -Exec=rekonq %u -X-DocPath=rekonq/index.html +Exec=rekonq %i +DocPath=rekonq/index.html Categories=Qt;KDE;Network; +Terminal=0 + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 51790586..938c98cd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,7 @@ SET( rekonq_SRCS autosaver.cpp browserapplication.cpp mainwindow.cpp +# rekonqview.cpp cookiejar.cpp downloadmanager.cpp edittableview.cpp @@ -46,8 +47,12 @@ TARGET_LINK_LIBRARIES( rekonq ${QT_QTWEBKIT_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} - ${QT_QTUITOOLS_LIBRARY} +# ${QT_QTUITOOLS_LIBRARY} ) INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} ) -# install(FILES kekonq.rc DESTINATION ${DATA_INSTALL_DIR}/rekonq) + +########### install files ############### + +#INSTALL( FILES rekonq.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) +INSTALL( FILES rekonqui.rc DESTINATION ${DATA_INSTALL_DIR}/rekonq ) diff --git a/src/Messages.sh b/src/Messages.sh new file mode 100644 index 00000000..7edde0a1 --- /dev/null +++ b/src/Messages.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +$EXTRACTRC `find . -name \*.rc` >> rc.cpp +$XGETTEXT *.cpp -o $podir/rekonq.pot +rm -f *.cpp \ No newline at end of file diff --git a/src/history.cpp b/src/history.cpp index 36a710b1..12a9d57f 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -668,7 +668,7 @@ void HistoryMenu::showHistoryDialog() } -void HistoryMenu::setInitialActions(QList actions) +void HistoryMenu::setInitialActions(QList actions) { m_initialActions = actions; for (int i = 0; i < m_initialActions.count(); ++i) diff --git a/src/history.h b/src/history.h index acd27192..4fac8cd6 100644 --- a/src/history.h +++ b/src/history.h @@ -38,6 +38,9 @@ #include +/** + * Elements in this class represent an history item + */ class HistoryItem { public: @@ -242,7 +245,7 @@ signals: public: HistoryMenu(QWidget *parent = 0); - void setInitialActions(QList actions); + void setInitialActions(QList actions); protected: bool prePopulated(); @@ -255,7 +258,7 @@ private slots: private: HistoryManager *m_history; HistoryMenuModel *m_historyMenuModel; - QList m_initialActions; + QList m_initialActions; }; diff --git a/src/main.cpp b/src/main.cpp index 7963405d..fb9bf3de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,33 +24,32 @@ #include #include +static const char description[] = + I18N_NOOP("KDE Browser Webkit Based"); + +static const char version[] = "0.0.2"; -// really simple writing main files today.. int main(int argc, char **argv) { - KAboutData aboutData( - "rekonq", - 0, - ki18n("rekonq"), - "0.0.1", - ki18n("A KDE browser webkit based"), - KAboutData::License_GPL, - ki18n("Copyright (c) 2008 Andrea Diamantini"), - KLocalizedString(), - "http://www.adjam.org", - "adjam7@gmail.com" // bug report mail - ); + KAboutData about( "rekonq", + 0, + ki18n("rekonq"), + version, + ki18n(description), + KAboutData::License_GPL, + ki18n("(C) 2008 Andrea Diamantini"), + KLocalizedString(), + "http://www.adjam.org", + "adjam7@gmail.com" + ); + + about.addAuthor( ki18n("Andrea Diamantini"), + KLocalizedString(), + "adjam7@gmail.com" + ); - aboutData.addAuthor( - ki18n("Andrea Diamantini"), - ki18n("rekonq author"), - "adjam7@gmail.com" - ); - - aboutData.setProgramIconName("applications-internet"); + KCmdLineArgs::init(argc, argv, &about); - KCmdLineArgs::init( argc, argv, &aboutData ); - KCmdLineOptions options; options.add( "+URL" , ki18n("Location to open") ); KCmdLineArgs::addCmdLineOptions( options ); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b57f5379..eb0543e9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -19,9 +19,10 @@  * ============================================================ */ -// Local Includes +// Self Includes #include "mainwindow.h" -#include "autosaver.h" + +// Local Includes #include "browserapplication.h" #include "downloadmanager.h" #include "history.h" @@ -54,365 +55,209 @@ #include -MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags) - : KMainWindow(parent, flags) - , m_tabWidget(new TabWidget(this)) - , m_autoSaver(new AutoSaver(this)) - , m_historyBack(0) - , m_historyForward(0) - , m_stop(0) - , m_reload(0) +MainWindow::MainWindow() + : KXmlGuiWindow() + , m_tabWidget( new TabWidget(this) ) { - // delete widget accepting close event - setAttribute(Qt::WA_DeleteOnClose, true); - - setupMenu(); - setupToolBar(); + // accept dnd + setAcceptDrops(true); - QWidget *centralWidget = new QWidget(this); + m_tabWidget->newTab(); - QVBoxLayout *layout = new QVBoxLayout; - layout->setSpacing(0); - layout->setMargin(0); - addToolBarBreak(); - layout->addWidget(m_tabWidget); + // tell the KXmlGuiWindow that this is indeed the main widget + setCentralWidget(m_tabWidget); // Find Bar m_findBar = new FindBar(this); connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); - centralWidget->setLayout(layout); - setCentralWidget(centralWidget); - connect(m_tabWidget, SIGNAL( loadPage(const QString &) ), this, SLOT( loadPage(const QString &) ) ); connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); - connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); +// connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); connect(m_tabWidget, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); - connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) ); +// connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) ); connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); slotUpdateWindowTitle(); - loadDefaultState(); - m_tabWidget->newTab(); -} +// -------------------------------------------------------------------------------------------------------------------------------- -MainWindow::~MainWindow() -{ - m_autoSaver->changeOccurred(); - m_autoSaver->saveIfNeccessary(); - delete m_navigationBar; -} + // then, setup our actions + setupActions(); + // add a status bar + statusBar()->show(); -void MainWindow::loadDefaultState() -{ - KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("MainWindow"); - QByteArray data = group1.readEntry(QString("defaultState"), QByteArray() ); - restoreState(data); -} + // a call to KXmlGuiWindow::setupGUI() populates the GUI + // with actions, using KXMLGUI. + // It also applies the saved mainwindow settings, if any, and ask the + // mainwindow to automatically save settings if changed: window size, + // toolbar position, icon size, etc. + setupGUI(); + // setup history & bookmarks menus + setupCustomMenu(); -void MainWindow::save() -{ - BrowserApplication::instance()->saveSession(); - - KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("MainWindow"); - QByteArray data = saveState(); - group1.writeEntry( QString("defaultState"), data ); - - KConfigGroup group2 = config.group("navigation toobar"); - m_navigationBar->saveSettings( group2 ); -} - - -static const qint32 MainWindowMagic = 0xba; + // setting up custom widgets.. + KToolBar *navigationBar = toolBar( "mainToolBar" ); + navigationBar->addWidget( m_tabWidget->lineEditStack() ); + m_searchBar = new SearchBar( this ); + connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + navigationBar->addWidget(m_searchBar); -QByteArray MainWindow::saveState() const -{ - int version = 2; - QByteArray data; - QDataStream stream(&data, QIODevice::WriteOnly); - - stream << qint32(MainWindowMagic); - stream << qint32(version); - - stream << size(); - stream << KToolBar::toolBarsLocked(); - bool b = true; // statusBar()->isVisible() ; FIXME - stream << b; - stream << QByteArray(); - return data; } - -void MainWindow::restoreState(const QByteArray &state) +MainWindow::~MainWindow() { - int version = 2; - QByteArray sd = state; - QDataStream stream(&sd, QIODevice::ReadOnly); - if ( stream.atEnd() ) - { - return; - } - - qint32 marker; - qint32 v; - stream >> marker; - stream >> v; - if (marker != MainWindowMagic || v != version) - { - return; - } - - QSize size; - bool showStatusbar; - bool toolbarsLocked; - QByteArray tabState; - - stream >> size; - stream >> toolbarsLocked; - stream >> showStatusbar; - - resize(size); - statusBar()->setVisible(showStatusbar); - updateStatusbarActionText(showStatusbar); - - KToolBar::setToolBarsLocked ( toolbarsLocked ); - return; } -void MainWindow::setupMenu() +void MainWindow::setupActions() { - // ------------------------------------------------------------- FILE -------------------------------------------------------------------------------------------------- - KMenu *fileMenu = (KMenu *) menuBar()->addMenu( i18n("&File") ); - - fileMenu->addAction( KStandardAction::openNew(this, SLOT( slotFileNew() ) , this ) ); - fileMenu->addAction( KStandardAction::open( this, SLOT( slotFileOpen() ), this ) ); - fileMenu->addAction( i18n("Open Location"), this, SLOT( slotSelectLineEdit() ) ); - fileMenu->addSeparator(); - - fileMenu->addAction( m_tabWidget->newTabAction() ); - fileMenu->addAction( m_tabWidget->closeTabAction() ); - fileMenu->addSeparator(); + KAction *a; - fileMenu->addAction( KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), this ) ); - fileMenu->addSeparator(); + // Standard Actions + KStandardAction::openNew(this, SLOT( slotFileNew() ) , actionCollection() ); + KStandardAction::open( this, SLOT( slotFileOpen() ), actionCollection() ); + KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), actionCollection() ); + KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), actionCollection() ); + KStandardAction::print( this, SLOT( slotFilePrint() ), actionCollection() ); + KStandardAction::quit( this , SLOT( close() ), actionCollection() ); + KStandardAction::find(this, SLOT( slotViewFindBar() ) , actionCollection() ); + KStandardAction::findNext(this, SLOT( slotFindNext() ) , actionCollection() ); + KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , actionCollection() ); + KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, actionCollection() ); + KStandardAction::home( this, SLOT( slotHome() ), actionCollection() ); - fileMenu->addAction( KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), this ) ); - fileMenu->addAction( KStandardAction::print( this, SLOT(slotFilePrint()), this) ); - fileMenu->addSeparator(); + a = KStandardAction::redisplay( this, 0, actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::Reload ); - KAction *action = (KAction *) fileMenu->addAction( i18n("Private &Browsing..."), this, SLOT( slotPrivateBrowsing() ) ); - action->setCheckable(true); - fileMenu->addSeparator(); + a = KStandardAction::back( this, 0, actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::Back ); - fileMenu->addAction( KStandardAction::quit( this , SLOT( close() ), this ) ); + a = KStandardAction::forward( this, 0, actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::Forward ); - // ------------------------------------------------------------- EDIT -------------------------------------------------------------------------------------------------- - KMenu *editMenu = (KMenu *) menuBar()->addMenu( i18n("&Edit") ); + a = KStandardAction::undo( this , 0 , actionCollection() ); + m_tabWidget->addWebAction( a , QWebPage::Undo ); - KAction *m_undo = KStandardAction::undo( this , 0 , this ); - editMenu->addAction( m_undo ); - m_tabWidget->addWebAction(m_undo, QWebPage::Undo); + a = KStandardAction::redo( this , 0 , actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::Redo ); - KAction *m_redo = KStandardAction::redo( this , 0 , this ); - editMenu->addAction( m_redo ); - m_tabWidget->addWebAction(m_redo, QWebPage::Redo); + a = KStandardAction::cut( this , 0 , actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::Cut ); - editMenu->addSeparator(); + a = KStandardAction::copy( this , 0 , actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::Copy ); - KAction *m_cut = KStandardAction::cut( this , 0 , this ); - editMenu->addAction( m_cut ); - m_tabWidget->addWebAction(m_cut, QWebPage::Cut); + a = KStandardAction::paste( this , 0 , actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::Paste ); - KAction *m_copy = KStandardAction::copy( this , 0 , this ); - editMenu->addAction( m_copy ); - m_tabWidget->addWebAction(m_copy, QWebPage::Copy); + a = KStandardAction::selectAll( this , 0 , actionCollection() ); + m_tabWidget->addWebAction( a, QWebPage::SelectEndOfDocument ); - KAction *m_paste = KStandardAction::paste( this , 0 , this ); - editMenu->addAction( m_paste ); - m_tabWidget->addWebAction(m_paste, QWebPage::Paste); + // stop reload Action + m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); + actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); - editMenu->addSeparator(); + // Custom Actions + a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); + a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); + actionCollection()->addAction( QLatin1String("stop"), a ); + m_tabWidget->addWebAction( a, QWebPage::Stop); + + a = new KAction( KIcon(), i18n("Open Location"), this); + actionCollection()->addAction( QLatin1String("open location"), a ); + connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotOpenLocation() ) ); - KAction *m_selectall = KStandardAction::selectAll( this , 0 , this ); - editMenu->addAction( m_selectall ); - m_tabWidget->addWebAction(m_selectall, QWebPage::SelectEndOfDocument ); + actionCollection()->addAction( QLatin1String("new tab"), m_tabWidget->newTabAction() ); + actionCollection()->addAction( QLatin1String("close tab"), m_tabWidget->closeTabAction() ); - editMenu->addSeparator(); + a = new KAction( i18n("Private &Browsing..."), this ); + a->setCheckable(true); + actionCollection()->addAction( i18n("private browsing"), a ); + connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotPrivateBrowsing() ) ); - editMenu->addAction( KStandardAction::find(this, SLOT( slotViewFindBar() ) , this ) ); - editMenu->addAction( KStandardAction::findNext(this, SLOT( slotFindNext() ) , this ) ); - editMenu->addAction( KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , this ) ); + a = new KAction( i18n("&Bigger"), this ); + a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Plus) ); + actionCollection()->addAction( QLatin1String("bigger font"), a ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextBigger() ) ); - // ------------------------------------------------------------- VIEW ------------------------------------------------------------------------------------------------- - KMenu *viewMenu = (KMenu *) menuBar()->addMenu( i18n("&View") ); + a = new KAction( i18n("&Normal"), this ); + a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_0) ); + actionCollection()->addAction( QLatin1String("normal font"), a ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextNormal() ) ); - m_viewStatusbar = KStandardAction::showStatusbar( this, SLOT(slotViewStatusbar() ), this); - viewMenu->addAction(m_viewStatusbar); + a = new KAction( i18n("&Smaller"), this ); + a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Minus) ); + actionCollection()->addAction( QLatin1String("smaller font"), a ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextSmaller() ) ); - viewMenu->addSeparator(); + a = new KAction( i18n("Page S&ource"), this ); + actionCollection()->addAction( QLatin1String("page source"), a ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewPageSource() ) ); - m_stop = (KAction *) viewMenu->addAction( KIcon( "process-stop" ), i18n("&Stop") ); - m_stop->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); - m_tabWidget->addWebAction(m_stop, QWebPage::Stop); + a = new KAction( KIcon( "kget" ), i18n("Downloads"), this ); + actionCollection()->addAction( QLatin1String("downloads"), a); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotDownloadManager() ) ); - m_reload = (KAction *) viewMenu->addAction( KIcon("view-refresh"), i18n("Reload Page") ); - m_reload->setShortcut(QKeySequence::Refresh); - m_tabWidget->addWebAction(m_reload, QWebPage::Reload); + a = new KAction( KIcon("page-zoom"), i18n("Enable Web &Inspector"), this ); + a->setCheckable(true); + actionCollection()->addAction( QLatin1String("web inspector"), a ); + connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotToggleInspector(bool) ) ); - viewMenu->addSeparator(); + // =================================================================================================================== + // =================================================================================================================== + // FIXME - KMenu *fontMenu = new KMenu( i18n("Make Text..."), this ); - fontMenu->addAction( i18n("&Bigger"), this, SLOT(slotViewTextBigger()), QKeySequence(Qt::CTRL | Qt::Key_Plus)); - fontMenu->addAction( i18n("&Normal"), this, SLOT(slotViewTextNormal()), QKeySequence(Qt::CTRL | Qt::Key_0)); - fontMenu->addAction( i18n("&Smaller"), this, SLOT(slotViewTextSmaller()), QKeySequence(Qt::CTRL | Qt::Key_Minus)); - - viewMenu->addMenu( fontMenu ); - - viewMenu->addSeparator(); - - // TODO set encoding + KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); + m_historyBackMenu = new KMenu(this); + historyBack->setMenu(m_historyBackMenu); + connect(historyBack, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenPrevious() ) ); + connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); + connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); + actionCollection()->addAction( QLatin1String("history back"), historyBack); - viewMenu->addAction( i18n("Page S&ource"), this, SLOT( slotViewPageSource() ), i18n("Ctrl+Alt+U")); + KAction *historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); + connect(historyForward, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenNext() ) ); + actionCollection()->addAction( QLatin1String("history forward"), m_historyForward ); +} - KToggleFullScreenAction *tfsa = KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, this); - viewMenu->addAction( tfsa ); - // ------------------------------------------------------------- HISTORY -------------------------------------------------------------------------------------------------- +void MainWindow::setupCustomMenu() +{ + // ------------------------------------------------------------- HISTORY MENU-------------------------------------------------------------------------------------------------- HistoryMenu *historyMenu = new HistoryMenu(this); connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle( i18n("Hi&story") ); menuBar()->addMenu(historyMenu); - QList historyActions; - - m_historyBack = new KAction( i18n("Back"), this); - m_historyBack->setShortcut( KShortcut( QKeySequence::Back ) ); - m_tabWidget->addWebAction( m_historyBack, QWebPage::Back ); - m_historyBack->setIconVisibleInMenu(false); - - m_historyForward = new KAction( i18n("Forward"), this); - m_historyForward->setShortcut( KShortcut( QKeySequence::Forward ) ); - m_tabWidget->addWebAction( m_historyForward, QWebPage::Forward ); - m_historyForward->setIconVisibleInMenu(false); + QList historyActions; - historyActions.append( m_historyBack ); - historyActions.append( m_historyForward ); - historyActions.append( KStandardAction::home(this, SLOT( slotHome() ) , this ) ); + historyActions.append( actionCollection()->action("Back") ); + historyActions.append( actionCollection()->action("Forward") ); + historyActions.append( actionCollection()->action("Home") ); historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); historyMenu->setInitialActions(historyActions); + // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - - - // ------------------------------------------------------------- BOOKMARKS -------------------------------------------------------------------------------------------------- - + // --------------------------------------------- BOOKMARKS MENU ----------------------------------------------------------------------------------------------------- BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); bookmarksMenu->setTitle( i18n("&Bookmarks") ); - menuBar()->addMenu( bookmarksMenu ); - - // ------------------------------------------------------------- TOOLS ------------------------------------------------------------------------------------------------------ - KMenu* toolsMenu = (KMenu *) menuBar()->addMenu( i18n("&Tools") ); - - toolsMenu->addAction( i18n("Downloads"), this, SLOT( slotDownloadManager() ), i18n("Alt+Ctrl+D") ); - - toolsMenu->addSeparator(); - - action = (KAction *) toolsMenu->addAction( i18n("Enable Web &Inspector"), this, SLOT(slotToggleInspector(bool))); - action->setCheckable(true); - - // ------------------------------------------------------------- SETTINGS ------------------------------------------------------------------------------------------------------ - KMenu *settingsMenu = (KMenu *) menuBar()->addMenu( i18n("&Settings") ); - - settingsMenu->addAction( KStandardAction::keyBindings( this, SLOT( configureShortcuts() ), this ) ); //FIXME need new slot and actionCollection !! - settingsMenu->addAction( KStandardAction::preferences(this, SLOT( slotPreferences() ) , this ) ); - - // ------------------------------------------------------------- HELP -------------------------------------------------------------------------------------------------- - menuBar()->addMenu( helpMenu() ); -} - - -void MainWindow::setupToolBar() -{ - m_navigationBar = new KToolBar( i18n("Navigation") , this, Qt::TopToolBarArea, false, false, true); - - m_historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); - m_historyBackMenu = new KMenu(this); - m_historyBack->setMenu(m_historyBackMenu); - connect(m_historyBack, SIGNAL( triggered() ), this, SLOT( slotOpenPrevious() ) ); - connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); - connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - m_navigationBar->addAction(m_historyBack); - - m_historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); - connect(m_historyForward, SIGNAL( triggered() ), this, SLOT( slotOpenNext() ) ); - m_navigationBar->addAction(m_historyForward); - - m_stopReload = new KAction( KIcon("view-refresh"), i18n("Reload"), this); - m_navigationBar->addAction(m_stopReload); - - m_goHome = new KAction( KIcon( "go-home" ), i18n("Home"),this); - m_navigationBar->addAction(m_goHome); - connect(m_goHome, SIGNAL(triggered()), this, SLOT(slotHome())); - - m_navigationBar->addWidget( m_tabWidget->lineEditStack() ); - - m_searchBar = new SearchBar( m_navigationBar ); - connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); - m_navigationBar->addWidget(m_searchBar); - - // UI settings - setContextMenuPolicy( Qt::PreventContextMenu ); - - // setting initial style (if user hasn't decided something else) - m_navigationBar->setIconDimensions(22); - m_navigationBar->setToolButtonStyle( Qt::ToolButtonIconOnly ); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("navigation toobar"); - if ( group.exists() ) - { - m_navigationBar->applySettings( group ); - } -} - - -void MainWindow::updateStatusbarActionText(bool visible) -{ - m_viewStatusbar->setText(!visible ? i18n("Show Status Bar") : i18n("Hide Status Bar")); -} - - -void MainWindow::slotViewStatusbar() -{ - if (statusBar()->isVisible()) - { - updateStatusbarActionText(false); - statusBar()->close(); - } - else - { - updateStatusbarActionText(true); - statusBar()->show(); - } - m_autoSaver->changeOccurred(); + menuBar()->addMenu(bookmarksMenu ); + // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ } - KUrl MainWindow::guessUrlFromString(const QString &string) { QString urlStr = string.trimmed(); @@ -480,7 +325,7 @@ void MainWindow::slotDownloadManager() } -void MainWindow::slotSelectLineEdit() +void MainWindow::slotOpenLocation() { m_tabWidget->currentLineEdit()->selectAll(); m_tabWidget->currentLineEdit()->setFocus(); @@ -607,22 +452,22 @@ void MainWindow::slotPrivateBrowsing() } -void MainWindow::closeEvent(QCloseEvent *event) -{ - if (m_tabWidget->count() > 1) - { - int ret = KMessageBox::warningYesNo(this, - i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , - i18n("Closing") ); - if (ret == KMessageBox::No) - { - event->ignore(); - return; - } - } - event->accept(); - deleteLater(); -} +// void MainWindow::closeEvent(QCloseEvent *event) +// { +// if (m_tabWidget->count() > 1) +// { +// int ret = KMessageBox::warningYesNo(this, +// i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , +// i18n("Closing") ); +// if (ret == KMessageBox::No) +// { +// event->ignore(); +// return; +// } +// } +// event->accept(); +// deleteLater(); +// } void MainWindow::slotFind(const QString & search) @@ -685,7 +530,7 @@ void MainWindow::slotViewTextSmaller() // TODO improve this -void MainWindow::slotViewFullScreen(bool makeFullScreen) +void MainWindow::slotViewFullScreen( bool makeFullScreen ) { KToggleFullScreenAction::setFullScreen( this, makeFullScreen ); } @@ -733,10 +578,14 @@ void MainWindow::slotToggleInspector(bool enable) void MainWindow::slotSwapFocus() { - if (currentTab()->hasFocus()) + if ( currentTab()->hasFocus() ) + { m_tabWidget->currentLineEdit()->setFocus(); + } else + { currentTab()->setFocus(); + } } @@ -764,23 +613,29 @@ WebView *MainWindow::currentTab() const } +// FIXME: this actually doesn't work properly.. void MainWindow::slotLoadProgress(int progress) { if (progress < 100 && progress > 0) { - disconnect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); - if (m_stopIcon.isNull()) - m_stopIcon = KIcon( "process-stop" ); - m_stopReload->setIcon(m_stopIcon); - connect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); +// disconnect(m_stopReload, SIGNAL( triggered( bool ) ), m_reload, SLOT( trigger() ) ); +// m_stopReload->setIcon( KIcon( "process-stop" ) ); +// connect(m_stopReload, SIGNAL( triggered( bool ) ), m_stop, SLOT( trigger() ) ); + + disconnect( m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "redisplay" ) , SIGNAL( triggered() ) ); + m_stopReload->setIcon( KIcon( "process-stop" ) ); + connect(m_stopReload, SIGNAL( triggered(bool ) ), actionCollection()->action( "stop" ), SLOT( triggered() ) ); m_stopReload->setToolTip( i18n("Stop loading the current page") ); } else { - disconnect(m_stopReload, SIGNAL(triggered()), m_stop, SLOT(trigger())); - m_stopReload->setIcon( KIcon("view-refresh") ); - connect(m_stopReload, SIGNAL(triggered()), m_reload, SLOT(trigger())); - m_stopReload->setToolTip( i18n("Reload the current page") ); +// disconnect(m_stopReload, SIGNAL( triggered( bool ) ), m_stop, SLOT( trigger() ) ); +// m_stopReload->setIcon( KIcon("view-refresh") ); +// connect(m_stopReload, SIGNAL( triggered( bool ) ), m_reload, SLOT( trigger() ) ); + disconnect( m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "stop" ) , SIGNAL( triggered( ) ) ); + m_stopReload->setIcon( KIcon( "view-refresh" ) ); + connect(m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "redisplay" ), SLOT( triggered() ) ); + m_stopReload->setToolTip( i18n("Reload the current page") ); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 6f78fd59..aa8e3d65 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -28,7 +28,7 @@ // KDE Includes #include -#include +#include #include #include #include @@ -36,7 +36,6 @@ #include -class AutoSaver; class QWebFrame; class TabWidget; class WebView; @@ -45,21 +44,21 @@ class WebView; The MainWindow of the Browser Application. Handles the tab widget and all the actions */ -class MainWindow : public KMainWindow +class MainWindow : public KXmlGuiWindow { Q_OBJECT public: - MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + MainWindow(); ~MainWindow(); static KUrl guessUrlFromString(const QString &url); TabWidget *tabWidget() const; WebView *currentTab() const; - - QByteArray saveState() const; - void restoreState(const QByteArray &state); +private: + void setupActions(); + void setupCustomMenu(); public slots: void loadPage(const QString &url); @@ -68,12 +67,7 @@ public slots: void slotFindNext(); void slotFindPrevious(); -protected: - void closeEvent(QCloseEvent *event); - private slots: - void save(); - void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); void slotUpdateWindowTitle(const QString &title = QString()); @@ -91,14 +85,13 @@ private slots: void slotViewTextBigger(); void slotViewTextNormal(); void slotViewTextSmaller(); - void slotViewStatusbar(); void slotViewPageSource(); void slotViewFullScreen(bool enable); void slotViewFindBar(); void slotToggleInspector(bool enable); void slotDownloadManager(); - void slotSelectLineEdit(); + void slotOpenLocation(); void slotAboutToShowBackMenu(); @@ -113,36 +106,19 @@ private slots: void printRequested(QWebFrame *frame); void geometryChangeRequested(const QRect &geometry); -private: - void loadDefaultState(); - void setupMenu(); - void setupToolBar(); - void updateStatusbarActionText(bool visible); private: - - KToolBar *m_navigationBar; SearchBar *m_searchBar; - TabWidget *m_tabWidget; - AutoSaver *m_autoSaver; + FindBar *m_findBar; - KAction *m_historyBack; KMenu *m_historyBackMenu; - KAction *m_historyForward; KMenu *m_windowMenu; - KAction *m_stop; - KAction *m_reload; - KAction *m_stopReload; - KAction *m_goHome; - KToggleAction *m_viewStatusbar; - KAction *m_restoreLastSession; - - KIcon m_reloadIcon; - KIcon m_stopIcon; + QAction *m_stopReload; - FindBar *m_findBar; QString m_lastSearch; + + TabWidget *m_tabWidget; }; #endif // MAINWINDOW_H diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp index f2cd0189..965ef0a4 100644 --- a/src/modelmenu.cpp +++ b/src/modelmenu.cpp @@ -22,7 +22,7 @@ ModelMenu::ModelMenu(QWidget * parent) - : QMenu(parent) + : KMenu(parent) , m_maxRows(7) , m_firstSeparator(-1) , m_maxWidth(-1) diff --git a/src/modelmenu.h b/src/modelmenu.h index fe08e673..16c413af 100644 --- a/src/modelmenu.h +++ b/src/modelmenu.h @@ -29,9 +29,10 @@ // KDE Includes #include #include +#include // A QMenu that is dynamically populated from a QAbstractItemModel -class ModelMenu : public QMenu +class ModelMenu : public KMenu { Q_OBJECT diff --git a/src/rekonqui.rc b/src/rekonqui.rc new file mode 100644 index 00000000..32397b16 --- /dev/null +++ b/src/rekonqui.rc @@ -0,0 +1,77 @@ + + + + + &File + + + + + + + + + + + + + + + + + + &Edit + + + + + + + + + + + + + + + &View + + + + make text.. + + + + + + + + + + + + + + + + &Settings + + + + + + + + + + + + Main Toolbar + + + + + + + diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 08ec1212..3a26266b 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -229,7 +229,7 @@ TabWidget::TabWidget(QWidget *parent) setTabBar(m_tabBar); // Actions - m_newTabAction = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); + m_newTabAction = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); m_newTabAction->setIconVisibleInMenu(false); connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); -- cgit v1.2.1 From b7fd88eef6b70df7dc05011657187f8c2f3b83d8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 29 Dec 2008 02:52:20 +0100 Subject: Better menus, icons.. --- .gitignore | 1 + src/mainwindow.cpp | 30 +++++++++++++----------------- src/rekonqui.rc | 8 +++++--- src/settings.cpp | 8 ++++---- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 0beafa56..ba630bde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ qtdemobrowser releases +src/.ctagsdb diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index eb0543e9..152b2ec7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -137,6 +137,7 @@ void MainWindow::setupActions() KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , actionCollection() ); KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, actionCollection() ); KStandardAction::home( this, SLOT( slotHome() ), actionCollection() ); + KStandardAction::preferences( this, SLOT( slotPreferences() ), actionCollection() ); a = KStandardAction::redisplay( this, 0, actionCollection() ); m_tabWidget->addWebAction( a, QWebPage::Reload ); @@ -229,7 +230,7 @@ void MainWindow::setupActions() KAction *historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); connect(historyForward, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenNext() ) ); - actionCollection()->addAction( QLatin1String("history forward"), m_historyForward ); + actionCollection()->addAction( QLatin1String("history forward"), historyForward ); } @@ -240,7 +241,7 @@ void MainWindow::setupCustomMenu() connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle( i18n("Hi&story") ); - menuBar()->addMenu(historyMenu); + menuBar()->insertMenu( actionCollection()->action("downloads"), historyMenu); QList historyActions; historyActions.append( actionCollection()->action("Back") ); @@ -254,7 +255,7 @@ void MainWindow::setupCustomMenu() // --------------------------------------------- BOOKMARKS MENU ----------------------------------------------------------------------------------------------------- BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); bookmarksMenu->setTitle( i18n("&Bookmarks") ); - menuBar()->addMenu(bookmarksMenu ); + menuBar()->insertMenu( actionCollection()->action("downloads"), bookmarksMenu ); // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ } @@ -616,26 +617,21 @@ WebView *MainWindow::currentTab() const // FIXME: this actually doesn't work properly.. void MainWindow::slotLoadProgress(int progress) { + QAction *stop = actionCollection()->action( "stop" ); + QAction *reload = actionCollection()->action(" redisplay" ); if (progress < 100 && progress > 0) { -// disconnect(m_stopReload, SIGNAL( triggered( bool ) ), m_reload, SLOT( trigger() ) ); -// m_stopReload->setIcon( KIcon( "process-stop" ) ); -// connect(m_stopReload, SIGNAL( triggered( bool ) ), m_stop, SLOT( trigger() ) ); - - disconnect( m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "redisplay" ) , SIGNAL( triggered() ) ); - m_stopReload->setIcon( KIcon( "process-stop" ) ); - connect(m_stopReload, SIGNAL( triggered(bool ) ), actionCollection()->action( "stop" ), SLOT( triggered() ) ); + disconnect( m_stopReload, SIGNAL( triggered( bool ) ), reload , SIGNAL( triggered(bool) ) ); + m_stopReload->setIcon( KIcon( "process-stop" ) ); + connect(m_stopReload, SIGNAL( triggered(bool ) ), stop, SIGNAL( triggered(bool) ) ); m_stopReload->setToolTip( i18n("Stop loading the current page") ); } else { -// disconnect(m_stopReload, SIGNAL( triggered( bool ) ), m_stop, SLOT( trigger() ) ); -// m_stopReload->setIcon( KIcon("view-refresh") ); -// connect(m_stopReload, SIGNAL( triggered( bool ) ), m_reload, SLOT( trigger() ) ); - disconnect( m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "stop" ) , SIGNAL( triggered( ) ) ); - m_stopReload->setIcon( KIcon( "view-refresh" ) ); - connect(m_stopReload, SIGNAL( triggered( bool ) ), actionCollection()->action( "redisplay" ), SLOT( triggered() ) ); - m_stopReload->setToolTip( i18n("Reload the current page") ); + disconnect( m_stopReload, SIGNAL( triggered( bool ) ), stop , SIGNAL( triggered(bool ) ) ); + m_stopReload->setIcon( KIcon( "view-refresh" ) ); + connect(m_stopReload, SIGNAL( triggered( bool ) ), reload, SIGNAL( triggered(bool) ) ); + m_stopReload->setToolTip( i18n("Reload the current page") ); } } diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 32397b16..5c4ef58e 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -48,20 +48,22 @@ + + + - - &Settings +&Settings - + diff --git a/src/settings.cpp b/src/settings.cpp index 3b82935f..23b04c83 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -77,8 +77,8 @@ Private::Private(SettingsDialog *parent) widget = new QWidget; appearanceUi.setupUi( widget ); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("Appearance") ); - pageItem->setIcon( KIcon("kfontview") ); + pageItem = parent->addPage( widget , i18n("Fonts") ); + pageItem->setIcon( KIcon("preferences-desktop-font") ); widget = new QWidget; privacyUi.setupUi( widget ); @@ -176,7 +176,7 @@ void SettingsDialog::loadFromSettings() // Appearance - KConfigGroup group2 = config.group("Appearance Settings"); + KConfigGroup group2 = config.group("Fonts Settings"); m_fixedFont = group2.readEntry( QString("fixedFont"), m_fixedFont ); m_standardFont = group2.readEntry( QString("standardFont"), m_standardFont ); @@ -262,7 +262,7 @@ void SettingsDialog::saveToSettings() } group1.writeEntry(QString("historyExpire"), idx ); - KConfigGroup group2 = config.group("Appearance Settings"); + KConfigGroup group2 = config.group("Fonts Settings"); group2.writeEntry(QString("fixedFont"), m_fixedFont); group2.writeEntry(QString("standardFont"), m_standardFont); -- cgit v1.2.1 From 6ebcdb1aa9e4a2f59cf1dd7e38a39be5d8e1c31b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 30 Dec 2008 16:11:37 +0100 Subject: Solved history && bookmarks menu problems.. YEAH!! --- src/mainwindow.cpp | 18 +++++++++++------- src/rekonqui.rc | 10 ++++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 152b2ec7..d3509e60 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -188,17 +188,17 @@ void MainWindow::setupActions() actionCollection()->addAction( i18n("private browsing"), a ); connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotPrivateBrowsing() ) ); - a = new KAction( i18n("&Bigger"), this ); + a = new KAction( KIcon("zoom-in"), i18n("&Enlarge font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Plus) ); actionCollection()->addAction( QLatin1String("bigger font"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextBigger() ) ); - a = new KAction( i18n("&Normal"), this ); + a = new KAction( KIcon("zoom-original"), i18n("&Normal font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_0) ); actionCollection()->addAction( QLatin1String("normal font"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextNormal() ) ); - a = new KAction( i18n("&Smaller"), this ); + a = new KAction( KIcon("zoom-out"), i18n("&Shrink font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Minus) ); actionCollection()->addAction( QLatin1String("smaller font"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextSmaller() ) ); @@ -216,6 +216,11 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("web inspector"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotToggleInspector(bool) ) ); + a = new KActionMenu( i18n("B&ookmarks"), this ); + actionCollection()->addAction( QLatin1String("bookmarks"), a ); + BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); + a->setMenu( bookmarksMenu ); + // =================================================================================================================== // =================================================================================================================== // FIXME @@ -241,7 +246,7 @@ void MainWindow::setupCustomMenu() connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle( i18n("Hi&story") ); - menuBar()->insertMenu( actionCollection()->action("downloads"), historyMenu); + menuBar()->insertMenu( actionCollection()->action("bookmarks"), historyMenu); QList historyActions; historyActions.append( actionCollection()->action("Back") ); @@ -253,9 +258,8 @@ void MainWindow::setupCustomMenu() // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ // --------------------------------------------- BOOKMARKS MENU ----------------------------------------------------------------------------------------------------- - BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); - bookmarksMenu->setTitle( i18n("&Bookmarks") ); - menuBar()->insertMenu( actionCollection()->action("downloads"), bookmarksMenu ); + + // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ } diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 5c4ef58e..a3502229 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -38,12 +38,12 @@ &View - - make text.. + + - + @@ -51,6 +51,8 @@ + + @@ -58,7 +60,7 @@ &Settings - + -- cgit v1.2.1 From 9cbf281f4df98feec4325dac050cc633e3bbfe2f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 30 Dec 2008 16:52:23 +0100 Subject: Fixed FindBar crash && refactored to look like kate searchbar --- src/bookmarks.cpp | 2 +- src/findbar.cpp | 15 +++++++++++---- src/findbar.h | 4 ++-- src/main.cpp | 28 ++++++++++++++-------------- src/mainwindow.cpp | 7 +++---- 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 63d15f7b..3cb65e38 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -55,7 +55,7 @@ QString OwnBookMarks::currentTitle() const } -// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------------- BookmarksMenu::BookmarksMenu(KMainWindow *parent) diff --git a/src/findbar.cpp b/src/findbar.cpp index 73f6c784..382f9b09 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -24,12 +24,12 @@ #include #include #include -#include #include +#include #include -FindBar::FindBar(KMainWindow *parent) +FindBar::FindBar(KXmlGuiWindow *parent) : KToolBar( "FindBar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) { @@ -47,8 +47,15 @@ FindBar::FindBar(KMainWindow *parent) connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), parent, SLOT( slotFindNext() ) ); addWidget( m_lineEdit ); - addAction( KStandardAction::findNext(parent, SLOT( slotFindNext() ) , this ) ); - addAction( KStandardAction::findPrev(parent, SLOT( slotFindPrevious() ) , this ) ); + KPushButton *findNext = new KPushButton( KIcon("go-down"), "&Next", this ); + KPushButton *findPrev = new KPushButton( KIcon("go-up"), "&Previous", this ); + // perhaps we don't need working on style.. +// findNext->setStyle(); +// findPrev->setStyle(); + connect( findNext, SIGNAL( clicked() ), parent, SLOT( slotFindNext() ) ); + connect( findPrev, SIGNAL( clicked() ), parent, SLOT( slotFindPrevious() ) ); + addWidget( findNext ); + addWidget( findPrev ); // we start off hidden hide(); diff --git a/src/findbar.h b/src/findbar.h index f8ef183e..4c73767c 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -23,14 +23,14 @@ #include #include -#include +#include class FindBar : public KToolBar { Q_OBJECT public: - FindBar(KMainWindow *parent); + FindBar(KXmlGuiWindow *parent); ~FindBar(); KLineEdit *lineEdit(); diff --git a/src/main.cpp b/src/main.cpp index fb9bf3de..0988b367 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,21 +32,21 @@ static const char version[] = "0.0.2"; int main(int argc, char **argv) { KAboutData about( "rekonq", - 0, - ki18n("rekonq"), - version, - ki18n(description), - KAboutData::License_GPL, - ki18n("(C) 2008 Andrea Diamantini"), - KLocalizedString(), - "http://www.adjam.org", - "adjam7@gmail.com" - ); + 0, + ki18n("rekonq"), + version, + ki18n(description), + KAboutData::License_GPL, + ki18n("(C) 2008 Andrea Diamantini"), + KLocalizedString(), + "http://www.adjam.org", + "adjam7@gmail.com" + ); - about.addAuthor( ki18n("Andrea Diamantini"), - KLocalizedString(), - "adjam7@gmail.com" - ); + about.addAuthor( ki18n("Andrea Diamantini"), + KLocalizedString(), + "adjam7@gmail.com" + ); KCmdLineArgs::init(argc, argv, &about); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d3509e60..7bf44d06 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -67,10 +67,6 @@ MainWindow::MainWindow() // tell the KXmlGuiWindow that this is indeed the main widget setCentralWidget(m_tabWidget); - // Find Bar - m_findBar = new FindBar(this); - connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); - connect(m_tabWidget, SIGNAL( loadPage(const QString &) ), this, SLOT( loadPage(const QString &) ) ); connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); @@ -112,6 +108,9 @@ MainWindow::MainWindow() connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); navigationBar->addWidget(m_searchBar); + // Find Bar + m_findBar = new FindBar(this); + connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); } -- cgit v1.2.1 From a1029a351ecc77ee6dbab08012db642c0dd61830 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 30 Dec 2008 17:00:29 +0100 Subject: Fixed Settings changes.. --- src/settings.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/settings.h b/src/settings.h index e76d6da6..79059ed6 100644 --- a/src/settings.h +++ b/src/settings.h @@ -21,9 +21,6 @@ #ifndef SETTINGS_H #define SETTINGS_H -// Local Includes -#include "ui_settings.h" - // KDE Includes #include -- cgit v1.2.1 From ff09defcd3ce26802866e689125548b059c4f2c3 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 30 Dec 2008 17:24:57 +0100 Subject: Final adjs for 0.0.2 --- src/findbar.cpp | 2 +- src/mainwindow.cpp | 2 +- src/rekonqui.rc | 45 +++++++++++++++++++++------------------------ 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/findbar.cpp b/src/findbar.cpp index 382f9b09..6df09de1 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -30,7 +30,7 @@ #include FindBar::FindBar(KXmlGuiWindow *parent) - : KToolBar( "FindBar" , parent, Qt::BottomToolBarArea, true, false, false) + : KToolBar( "Find Bar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) { KAction *close = new KAction(KIcon("dialog-close") , "close" , this); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7bf44d06..3e0d71fa 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -109,7 +109,7 @@ MainWindow::MainWindow() navigationBar->addWidget(m_searchBar); // Find Bar - m_findBar = new FindBar(this); + m_findBar = new FindBar( this ); connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); } diff --git a/src/rekonqui.rc b/src/rekonqui.rc index a3502229..a7ab8cfb 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -2,7 +2,7 @@ - &File +&File @@ -18,9 +18,9 @@ - - - &Edit + + +&Edit @@ -33,45 +33,42 @@ - - - &View + + +&View - - - - - - + + + - + - - + + - + &Settings - - - - - + + + + + + - - Main Toolbar +Main Toolbar -- cgit v1.2.1 From e8b08487a54938fc711c88cba9376e03cea3f319 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 31 Dec 2008 00:05:55 +0100 Subject: minor changes added doc subdir --- CMakeLists.txt | 7 +- doc/CMakeLists.txt | 4 + doc/index.docbook | 569 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 577 insertions(+), 3 deletions(-) create mode 100644 doc/CMakeLists.txt create mode 100644 doc/index.docbook diff --git a/CMakeLists.txt b/CMakeLists.txt index 51354090..70606704 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ PROJECT( rekonq ) # rekonq version SET(REKONQ_MAJOR_VERSION "0") SET(REKONQ_MINOR_VERSION "0") -SET(REKONQ_PATCH_VERSION "1") +SET(REKONQ_PATCH_VERSION "2") SET(REKONQ_VERSION_STRING "${REKONQ_MAJOR_VERSION}.${REKONQ_MINOR_VERSION}.${REKONQ_PATCH_VERSION}" @@ -23,7 +23,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) # ================================================================================================= -SET( QT_MIN_VERSION 4.4.0) +SET(QT_MIN_VERSION 4.4.0) FIND_PACKAGE(KDE4 REQUIRED) INCLUDE(MacroOptionalFindPackage) @@ -60,7 +60,7 @@ IF(QT_FOUND) MESSAGE(STATUS " rekonq will be compiled....... YES") SET(REKONQ_CAN_BE_COMPILED true) ELSE(QT_FOUND) - MESSAGE(FATAL_ERROR " rekonq will not be compiled!") + MESSAGE(FATAL_ERROR " rekonq will NOT be compiled!") SET(REKONQ_CAN_BE_COMPILED false) ENDIF(QT_FOUND) @@ -83,6 +83,7 @@ IF(REKONQ_CAN_BE_COMPILED) ADD_SUBDIRECTORY( icons ) ADD_SUBDIRECTORY( data ) ADD_SUBDIRECTORY( htmls ) + ADD_SUBDIRECTORY( doc ) ENDIF(REKONQ_CAN_BE_COMPILED) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..3a54287f --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,4 @@ +########### install files ############### +# + +kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR rekonq) diff --git a/doc/index.docbook b/doc/index.docbook new file mode 100644 index 00000000..e9b64bd5 --- /dev/null +++ b/doc/index.docbook @@ -0,0 +1,569 @@ + + + rekonq"> + + + + + + +]> + + + + + + + + + + + + + + +The &kmyapplication; Handbook + + + + + +George +N. +Ugnacious + +gnu@kde.org + + + + + + +2008 +George N. Ugnacious + + + +&FDLNotice; + + + +2008-01-10 +1.01.00 + + + + + +&kmyapplication; is an application specially designed to do nothing you would +ever want. + + + + + + +KDE +kdeutils +Kapp +nothing +nothing else + + + + + + + +Introduction + + + + +&kmyapplication; is a program that lets you do absolutely nothing. Please report +any problems or feature requests to the &kde; mailing lists. + + + + +Using &kmyapplication; + + + + + + + + +Here's a screenshot of &kmyapplication; + + + + + + + + + Screenshot + + + + + + + +More &kmyapplication; features + +It slices! It dices! and it comes with a free toaster! + +The Squiggle Tool + + + + + + + + Squiggle + + is used to draw squiggly lines all over +the &kmyapplication; main window. It's not a bug, it's a feature! + + + + + + +Command Reference + + + + +The main &kmyapplication; window + + +The File Menu + + + + + +&Ctrl;N + +File +New + +Creates a new document + + + + +&Ctrl;S + +File +Save + +Saves the document + + + + +&Ctrl;Q + +File +Quit + +Quits &kmyapplication; + + + + + + + +The <guimenu>Help</guimenu> Menu + + + + + + +&help.menu.documentation; + + + + + + + +Developer's Guide to &kmyapplication; + + + + +Programming &kmyapplication; plugins is a joy to behold. Just read through the next +66 pages of API's to learn how! + + + + + + +XtUnmanageChildren +Xt - Geometry Management + + +XtUnmanageChildren + +remove a list of children from a parent widget's managed +list. +widgetsremoving +XtUnmanageChildren + + + + + +4 March 1996 + + +void XtUnmanageChildren(children, num_children) + WidgetList children; + Cardinal num_children; + + + +Inputs + + +children + + +Specifies an array of child widgets. Each child must be of +class RectObj or any subclass thereof. + + + + +num_children + + +Specifies the number of elements in children. + + + + + + + +Description + +XtUnmanageChildren() unmaps the specified widgets +and removes them from their parent's geometry management. +The widgets will disappear from the screen, and (depending +on its parent) may no longer have screen space allocated for +them. + +Each of the widgets in the children array must have +the same parent. + +See the “Algorithm” section below for full details of the +widget unmanagement procedure. + + + + +Usage +Unmanaging widgets is the usual method for temporarily +making them invisible. They can be re-managed with +XtManageChildren(). + +You can unmap a widget, but leave it under geometry +management by calling XtUnmapWidget(). You can +destroy a widget's window without destroying the widget by +calling XtUnrealizeWidget(). You can destroy a +widget completely with XtDestroyWidget(). + +If you are only going to unmanage a single widget, it is +more convenient to call XtUnmanageChild(). It is +often more convenient to call XtUnmanageChild() +several times than it is to declare and initialize an array +of widgets to pass to XtUnmanageChildren(). Calling +XtUnmanageChildren() is more efficient, however, +because it only calls the parent's change_managed() +method once. + + + + +Algorithm + +XtUnmanageChildren() performs the following: + + + +- + + +Ignores the child if it already is unmanaged or is being +destroyed. + + + + +- + + +Otherwise, if the child is realized, it makes it nonvisible +by unmapping it. + + + + + + + + + +Structures +The WidgetList type is simply an array of widgets: + +typedef Widget *WidgetList; + + + + + + + +Questions and Answers + + + +&reporting.bugs; +&updating.documentation; + + + + +My Mouse doesn't work. How do I quit &kmyapplication;? + + +You silly goose! Check out the Commands +Section for the answer. + + + + +Why can't I twiddle my documents? + + +You can only twiddle your documents if you have the foobar.lib +installed. + + + + + + + + + +Credits and License + + +&kmyapplication; + + +Program copyright 2008 John Q. Hacker jqh@kde.org + + +Contributors: + +Konqui the KDE Dragon konqui@kde.org + +Tux the Linux Penguin tux@linux.org + + + + + +Documentation Copyright © 2008 George N. Ugnacious gnu@kde.org + + + + +&underFDL; + + + +&underGPL; +&underBSDLicense; +&underArtisticLicense; +&underX11License; + + + + +Installation + + +How to obtain &kmyapplication; + + + +&install.intro.documentation; + + + + +Requirements + + + + +In order to successfully use &kmyapplication;, you need &kde; 1.1. Foobar.lib is +required in order to support the advanced &kmyapplication; features. &kmyapplication; uses +about 5 megs of memory to run, but this may vary depending on your +platform and configuration. + + + +All required libraries as well as &kmyapplication; itself can be found +on The &kmyapplication; home page. + + + + +You can find a list of changes at http://apps.kde.org/kapp. + + + + +Compilation and Installation + + + + + +&install.compile.documentation; + + + + +Configuration + +Don't forget to tell your system to start the dtd +dicer-toaster daemon first, or &kmyapplication; won't work ! + + + + + +&documentation.index; + + + -- cgit v1.2.1 From 239b3f0059c73680ddab5026b2c343b8678f4393 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 31 Dec 2008 00:11:49 +0100 Subject: Icons (waiting for mine..) --- icons/hi16-app-rekonq.png | Bin 682 -> 832 bytes icons/hi32-app-rekonq.png | Bin 0 -> 1719 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 icons/hi32-app-rekonq.png diff --git a/icons/hi16-app-rekonq.png b/icons/hi16-app-rekonq.png index 2f3a9c01..e557f173 100644 Binary files a/icons/hi16-app-rekonq.png and b/icons/hi16-app-rekonq.png differ diff --git a/icons/hi32-app-rekonq.png b/icons/hi32-app-rekonq.png new file mode 100644 index 00000000..8d87115a Binary files /dev/null and b/icons/hi32-app-rekonq.png differ -- cgit v1.2.1 From 9462f40648cc980f101c42875936d2d27aa5616c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 31 Dec 2008 00:37:06 +0100 Subject: Final settings for 0.0.2 release --- ChangeLog | 10 +++++++--- FEATURES | 32 -------------------------------- TODO | 3 --- 3 files changed, 7 insertions(+), 38 deletions(-) delete mode 100644 FEATURES diff --git a/ChangeLog b/ChangeLog index 87465a3c..1e858a26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,11 @@ 0.0.2 -- QUrl --> KUrl -- more KDE-like toolbars +- 70% ported to KDE4 +- new urlbar +- new searchbar (just Google, for now) +- new findbar (A-LA kate) +- Slackware Slackbuild available 0.0.1 - +- initial porting to KDE4 +- share konqueror bookmarks diff --git a/FEATURES b/FEATURES deleted file mode 100644 index 43689398..00000000 --- a/FEATURES +++ /dev/null @@ -1,32 +0,0 @@ -TODO = - -DONE = + - -- fully ported to KDE4 -+ Kconfig support (obviously..) -- threadweaver support -- kwallet support -- dbus support - -- kget support -- simple download support - -- share konqueror's bookmarks (akonadi) -- kio_bookmarks support -- NO bookmark manager (doing it with kio_bookmarks) - -- rewamp history -- new kio_history implementation - -- find text bar (a-la kate) - -- cookies -- webkit's inspector - -- Crash recovery handler - -- search bar (like konq-plugin, but "always" plugged in!!) -- Web Shortcuts (i.e. 'gg:reKonq' to search google for reKonq) - -- Adblock support - ---- 0.1 release --- diff --git a/TODO b/TODO index f68c7845..98b5bae2 100644 --- a/TODO +++ b/TODO @@ -20,9 +20,6 @@ ROAD to 0.0.2 (second release) NEXT.. - system SELECT ALL - better FULL SCREEN -- simplify history -- KDE autosave -- kMainWindow save/read settings - color progress - contextMenu in searchbar to set different search engines - KDE proxy support -- cgit v1.2.1 From 412075ca56dc2182ea12dcd52e6cce5396575ae8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 31 Dec 2008 00:39:09 +0100 Subject: New rekonq site --- INSTALL | 27 +++++++++++++++++++++++++++ src/main.cpp | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 INSTALL diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..3d8888a0 --- /dev/null +++ b/INSTALL @@ -0,0 +1,27 @@ +===== Building rekonq from sources ===== + +=== Prerequisites === + +Qt4.4.x: + + Qt should be prepackaged for all mayor linux distributions. Please see + http://www.trolltech.com/products/qt for more information and installation + instructions. + +KDE 4 + + KDE 4.1 (or better) should be prepackaged for all mayor linux distributions. Please see + http://techbase.kde.org/Getting_Started/Build/stable_Version + for instructions on how to build and setup a KDE4 environment to work in. + + +=== Building rekonq === + + To build it do the following after switching into the source directory: + + mkdir build && cd build + cmake .. + make && make install + +Enjoy. +adjam diff --git a/src/main.cpp b/src/main.cpp index 0988b367..e53eef3c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) KAboutData::License_GPL, ki18n("(C) 2008 Andrea Diamantini"), KLocalizedString(), - "http://www.adjam.org", + "http://rekonq.adjam.org", "adjam7@gmail.com" ); -- cgit v1.2.1 From 0f11df2f16d30ed5edcd0db1f129078bd02338c5 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 7 Jan 2009 17:09:53 +0100 Subject: Removed setFocus from lineEdit->currentWebview so that people can switch trough tabs with CTRL tabbing --- TODO | 7 +++++++ src/history.h | 2 +- src/mainwindow.cpp | 35 +++++++++-------------------------- src/rekonqui.rc | 3 +-- src/tabwidget.cpp | 28 ++++++++++------------------ 5 files changed, 28 insertions(+), 47 deletions(-) diff --git a/TODO b/TODO index 98b5bae2..870e00fd 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,13 @@ ROAD to 0.0.2 (second release) - better find toolbar - fixed search bar width +ROAD to 0.0.3 (third release) +- mainview +- autosave-- && downloadSystem-- +- dbus, kjob, kget support +- new application class!! + + + -------------------------------- 0.0.2 + QUrl --> KUrl diff --git a/src/history.h b/src/history.h index 4fac8cd6..f3813855 100644 --- a/src/history.h +++ b/src/history.h @@ -130,7 +130,7 @@ private: }; -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// --------------------------------------------------------------------------------------------------------------------------------- class HistoryModel : public QAbstractTableModel diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3e0d71fa..d99ccd46 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -138,32 +138,15 @@ void MainWindow::setupActions() KStandardAction::home( this, SLOT( slotHome() ), actionCollection() ); KStandardAction::preferences( this, SLOT( slotPreferences() ), actionCollection() ); - a = KStandardAction::redisplay( this, 0, actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::Reload ); - - a = KStandardAction::back( this, 0, actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::Back ); - - a = KStandardAction::forward( this, 0, actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::Forward ); - - a = KStandardAction::undo( this , 0 , actionCollection() ); - m_tabWidget->addWebAction( a , QWebPage::Undo ); - - a = KStandardAction::redo( this , 0 , actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::Redo ); - - a = KStandardAction::cut( this , 0 , actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::Cut ); - - a = KStandardAction::copy( this , 0 , actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::Copy ); - - a = KStandardAction::paste( this , 0 , actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::Paste ); - - a = KStandardAction::selectAll( this , 0 , actionCollection() ); - m_tabWidget->addWebAction( a, QWebPage::SelectEndOfDocument ); + m_tabWidget->addWebAction( KStandardAction::redisplay( this, 0, actionCollection() ) , QWebPage::Reload ); + m_tabWidget->addWebAction( KStandardAction::back( this, 0, actionCollection() ) , QWebPage::Back ); + m_tabWidget->addWebAction( KStandardAction::forward( this, 0, actionCollection() ) , QWebPage::Forward ); + m_tabWidget->addWebAction( KStandardAction::undo( this , 0 , actionCollection() ) , QWebPage::Undo ); + m_tabWidget->addWebAction( KStandardAction::redo( this , 0 , actionCollection() ) , QWebPage::Redo ); + m_tabWidget->addWebAction( KStandardAction::cut( this , 0 , actionCollection() ) , QWebPage::Cut ); + m_tabWidget->addWebAction( KStandardAction::copy( this , 0 , actionCollection() ) , QWebPage::Copy ); + m_tabWidget->addWebAction( KStandardAction::paste( this , 0 , actionCollection() ) , QWebPage::Paste ); + m_tabWidget->addWebAction( KStandardAction::selectAll( this , 0 , actionCollection() ) , QWebPage::SelectEndOfDocument ); // stop reload Action m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); diff --git a/src/rekonqui.rc b/src/rekonqui.rc index a7ab8cfb..ef566c23 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -63,7 +63,6 @@ - diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp index 3a26266b..4af3ef60 100644 --- a/src/tabwidget.cpp +++ b/src/tabwidget.cpp @@ -295,8 +295,7 @@ void TabWidget::clear() void TabWidget::moveTab(int fromIndex, int toIndex) { - disconnect(this, SIGNAL(currentChanged(int)), - this, SLOT(currentChanged(int))); + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); QWidget *tabWidget = widget(fromIndex); QIcon icon = tabIcon(fromIndex); @@ -343,20 +342,14 @@ void TabWidget::currentChanged(int index) WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); if (oldWebView) { - disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), - this, SIGNAL(showStatusBarMessage(const QString&))); - disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), - this, SIGNAL(linkHovered(const QString&))); - disconnect(oldWebView, SIGNAL(loadProgress(int)), - this, SIGNAL(loadProgress(int))); + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); } - connect(webView, SIGNAL(statusBarMessage(const QString&)), - this, SIGNAL(showStatusBarMessage(const QString&))); - connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), - this, SIGNAL(linkHovered(const QString&))); - connect(webView, SIGNAL(loadProgress(int)), - this, SIGNAL(loadProgress(int))); + connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); + connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); for (int i = 0; i < m_actions.count(); ++i) { @@ -367,10 +360,9 @@ void TabWidget::currentChanged(int index) m_lineEdits->setCurrentIndex(index); emit loadProgress(webView->progress()); emit showStatusBarMessage(webView->lastStatusBarText()); - if (webView->url().isEmpty()) - m_lineEdits->currentWidget()->setFocus(); - else - webView->setFocus(); + + // set focus to the current webview + webView->setFocus(); } -- cgit v1.2.1 From e584eeaf35a7db2ee6e5c63ef3fcf32b92474df1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 8 Jan 2009 01:49:02 +0100 Subject: Little changes.. --- src/mainwindow.cpp | 14 +++++++------- src/rekonqui.rc | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d99ccd46..9813cf1e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -77,7 +77,6 @@ MainWindow::MainWindow() connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); connect(m_tabWidget, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); -// connect(m_tabWidget, SIGNAL( toolBarVisibilityChangeRequested(bool) ), m_navigationBar, SLOT( setVisible(bool) ) ); connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); slotUpdateWindowTitle(); @@ -223,7 +222,7 @@ void MainWindow::setupActions() void MainWindow::setupCustomMenu() { - // ------------------------------------------------------------- HISTORY MENU-------------------------------------------------------------------------------------------------- + // -------------------------------- HISTORY MENU ----------------------------------------------------------------------- HistoryMenu *historyMenu = new HistoryMenu(this); connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); @@ -237,12 +236,12 @@ void MainWindow::setupCustomMenu() historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); historyMenu->setInitialActions(historyActions); - // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + //-------------------------------------------------------------------------------------------------------------- - // --------------------------------------------- BOOKMARKS MENU ----------------------------------------------------------------------------------------------------- + // ------------------------------ BOOKMARKS MENU -------------------------------------------------------------- - // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + // ------------------------------------------------------------------------------------------------------------- } KUrl MainWindow::guessUrlFromString(const QString &string) @@ -444,8 +443,9 @@ void MainWindow::slotPrivateBrowsing() // if (m_tabWidget->count() > 1) // { // int ret = KMessageBox::warningYesNo(this, -// i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ) , -// i18n("Closing") ); +// i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ), +// i18n("Closing") +// ); // if (ret == KMessageBox::No) // { // event->ignore(); diff --git a/src/rekonqui.rc b/src/rekonqui.rc index ef566c23..1022fb20 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -36,7 +36,7 @@ &View - + -- cgit v1.2.1 From 6cf7ab65f009f07cdc0ded9ec377665c124a84ac Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 8 Jan 2009 02:35:46 +0100 Subject: Created mainview! Other minor adjs.. --- src/CMakeLists.txt | 4 +- src/browserapplication.cpp | 2 +- src/findbar.cpp | 6 +- src/findbar.h | 2 +- src/mainview.cpp | 704 ++++++++++++++++++++++++++++++++++++ src/mainview.h | 178 ++++++++++ src/mainwindow.cpp | 6 +- src/mainwindow.h | 6 +- src/tabbar.cpp | 207 +++++++++++ src/tabbar.h | 74 ++++ src/tabwidget.cpp | 863 --------------------------------------------- src/tabwidget.h | 218 ------------ src/webview.cpp | 2 +- 13 files changed, 1179 insertions(+), 1093 deletions(-) create mode 100644 src/mainview.cpp create mode 100644 src/mainview.h create mode 100644 src/tabbar.cpp create mode 100644 src/tabbar.h delete mode 100644 src/tabwidget.cpp delete mode 100644 src/tabwidget.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 938c98cd..83297551 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,8 @@ SET( rekonq_SRCS autosaver.cpp browserapplication.cpp mainwindow.cpp -# rekonqview.cpp + mainview.cpp + tabbar.cpp cookiejar.cpp downloadmanager.cpp edittableview.cpp @@ -16,7 +17,6 @@ SET( rekonq_SRCS searchbar.cpp settings.cpp squeezelabel.cpp - tabwidget.cpp webview.cpp main.cpp ) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 696b2cd8..bc29d64e 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -27,7 +27,7 @@ #include "downloadmanager.h" #include "history.h" #include "networkaccessmanager.h" -#include "tabwidget.h" +#include "mainview.h" #include "webview.h" // KDE Includes diff --git a/src/findbar.cpp b/src/findbar.cpp index 6df09de1..a1c867c2 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -17,9 +17,11 @@  *  * ============================================================ */ +// Self Includes #include "findbar.h" -#include "moc_findbar.cpp" +#include "findbar.moc" +// KDE Includes #include #include #include @@ -27,8 +29,10 @@ #include #include +// Qt Includes #include + FindBar::FindBar(KXmlGuiWindow *parent) : KToolBar( "Find Bar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) diff --git a/src/findbar.h b/src/findbar.h index 4c73767c..d70a9de1 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -20,9 +20,9 @@ #ifndef FINDBAR_H #define FINDBAR_H +// KDE Includes #include #include - #include class FindBar : public KToolBar diff --git a/src/mainview.cpp b/src/mainview.cpp new file mode 100644 index 00000000..79cb865d --- /dev/null +++ b/src/mainview.cpp @@ -0,0 +1,704 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes +#include "mainview.h" + +#include "tabbar.h" +#include "browserapplication.h" +#include "mainwindow.h" +#include "history.h" +#include "urlbar.h" +#include "webview.h" + +// KDE Includes +#include +#include +#include + +// Qt Includes +#include +#include + + + + +WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) + : QObject(parent) + , m_currentParent(0) + , m_root(root) + , m_webAction(webAction) +{ + if ( !m_root ) + { + return; + } + connect(m_root, SIGNAL( triggered() ), this, SLOT( rootTriggered() ) ); + connect(root, SIGNAL( destroyed(QObject *) ), this, SLOT( rootDestroyed() ) ); + + root->setEnabled(false); +} + + +void WebActionMapper::rootDestroyed() +{ + m_root = 0; +} + + +void WebActionMapper::currentDestroyed() +{ + updateCurrent(0); +} + + +void WebActionMapper::addChild(KAction *action) +{ + if ( !action ) + { + return; + } + connect(action, SIGNAL( changed() ), this, SLOT( childChanged() ) ); +} + +QWebPage::WebAction WebActionMapper::webAction() const +{ + return m_webAction; +} + + +void WebActionMapper::rootTriggered() +{ + if (m_currentParent) + { + KAction *gotoAction = new KAction( m_currentParent->action(m_webAction) ); + gotoAction->trigger(); + } +} + + +void WebActionMapper::childChanged() +{ + if (KAction *source = qobject_cast(sender())) + { + if (m_root + && m_currentParent + && source->parent() == m_currentParent) + { + m_root->setChecked(source->isChecked()); + m_root->setEnabled(source->isEnabled()); + } + } +} + + +void WebActionMapper::updateCurrent(QWebPage *currentParent) +{ + if (m_currentParent) + disconnect(m_currentParent, SIGNAL(destroyed(QObject *)), + this, SLOT(currentDestroyed())); + + m_currentParent = currentParent; + if (!m_root) + { + return; + } + if (!m_currentParent) + { + m_root->setEnabled(false); + m_root->setChecked(false); + return; + } + KAction *source = new KAction( m_currentParent->action(m_webAction) ); + m_root->setChecked(source->isChecked()); + m_root->setEnabled(source->isEnabled()); + connect(m_currentParent, SIGNAL( destroyed(QObject *) ), this, SLOT( currentDestroyed() ) ); +} + + +// ---------------------------------------------------------------------------------------------------------- + + +MainView::MainView(QWidget *parent) + : KTabWidget(parent) + , m_recentlyClosedTabsAction(0) + , m_newTabAction(0) + , m_closeTabAction(0) + , m_nextTabAction(0) + , m_previousTabAction(0) + , m_recentlyClosedTabsMenu(0) + , m_lineEditCompleter(0) + , m_lineEdits(0) + , m_tabBar(new TabBar(this)) +{ + setElideMode(Qt::ElideRight); + + connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); + connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); + connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); + connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); + connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); + connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); + connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); + setTabBar(m_tabBar); + + // Actions + m_newTabAction = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); + m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); + m_newTabAction->setIconVisibleInMenu(false); + connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); + + m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); + m_closeTabAction->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); + m_closeTabAction->setIconVisibleInMenu(false); + connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); + + m_nextTabAction = new KAction(i18n("Show Next Tab"), this); + m_nextTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); + connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); + + m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); + m_previousTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); + connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); + + m_recentlyClosedTabsMenu = new KMenu(this); + connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); + connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); + m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); + m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); + m_recentlyClosedTabsAction->setEnabled(false); + + // corner buttons + QToolButton *addTabButton = new QToolButton(this); + addTabButton->setDefaultAction(m_newTabAction); + addTabButton->setAutoRaise(true); + addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + setCornerWidget(addTabButton, Qt::TopLeftCorner); + + QToolButton *closeTabButton = new QToolButton(this); + closeTabButton->setDefaultAction(m_closeTabAction); + closeTabButton->setAutoRaise(true); + closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + setCornerWidget(closeTabButton, Qt::TopRightCorner); + + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + + m_lineEdits = new QStackedWidget(this); +} + + +MainView::~MainView() +{ + delete m_lineEditCompleter; + delete m_recentlyClosedTabsMenu; +} + + +void MainView::clear() +{ + // clear the recently closed tabs + m_recentlyClosedTabs.clear(); + // clear the line edit history + for (int i = 0; i < m_lineEdits->count(); ++i) + { + QLineEdit *qLineEdit = lineEdit(i); + qLineEdit->setText(qLineEdit->text()); + } +} + + +void MainView::moveTab(int fromIndex, int toIndex) +{ + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + + QWidget *tabWidget = widget(fromIndex); + QIcon icon = tabIcon(fromIndex); + QString text = tabText(fromIndex); + QVariant data = m_tabBar->tabData(fromIndex); + removeTab(fromIndex); + insertTab(toIndex, tabWidget, icon, text); + m_tabBar->setTabData(toIndex, data); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + setCurrentIndex(toIndex); +} + + +// When index is -1 index chooses the current tab +void MainView::reloadTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + QWidget *widget = this->widget(index); + if (WebView *tab = qobject_cast(widget)) + tab->reload(); +} + + +void MainView::addWebAction(KAction *action, QWebPage::WebAction webAction) +{ + if (!action) + return; + m_webActionList.append(new WebActionMapper(action, webAction, this)); +} + + +void MainView::currentChanged(int index) +{ + WebView *webView = this->webView(index); + if (!webView) + return; + + Q_ASSERT( m_lineEdits->count() == count() ); + + WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); + if (oldWebView) + { + disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); + disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); + } + + connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); + connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); + connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); + + for (int i = 0; i < m_webActionList.count(); ++i) + { + WebActionMapper *mapper = m_webActionList[i]; + mapper->updateCurrent(webView->page()); + } + emit setCurrentTitle(webView->title()); + m_lineEdits->setCurrentIndex(index); + emit loadProgress(webView->progress()); + emit showStatusBarMessage(webView->lastStatusBarText()); + + // set focus to the current webview + webView->setFocus(); +} + + +KAction *MainView::newTabAction() const +{ + return m_newTabAction; +} + + +KAction *MainView::closeTabAction() const +{ + return m_closeTabAction; +} + + +KAction *MainView::recentlyClosedTabsAction() const +{ + return m_recentlyClosedTabsAction; +} + + +KAction *MainView::nextTabAction() const +{ + return m_nextTabAction; +} + + +KAction *MainView::previousTabAction() const +{ + return m_previousTabAction; +} + + +QWidget *MainView::lineEditStack() const +{ + return m_lineEdits; +} + + +QLineEdit *MainView::currentLineEdit() const +{ + return lineEdit(m_lineEdits->currentIndex()); +} + + +WebView *MainView::currentWebView() const +{ + return webView(currentIndex()); +} + + +QLineEdit *MainView::lineEdit(int index) const +{ + UrlBar *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); + if (urlLineEdit) + return urlLineEdit->lineEdit(); + return 0; +} + + +WebView *MainView::webView(int index) const +{ + QWidget *widget = this->widget(index); + if (WebView *webView = qobject_cast(widget)) + { + return webView; + } + else + { + // optimization to delay creating the first webview + if (count() == 1) + { + MainView *that = const_cast(this); + that->setUpdatesEnabled(false); + that->newTab(); + that->closeTab(0); + that->setUpdatesEnabled(true); + return currentWebView(); + } + } + return 0; +} + + +int MainView::webViewIndex(WebView *webView) const +{ + int index = indexOf(webView); + return index; +} + + +WebView *MainView::newTab(bool makeCurrent) +{ + // line edit + UrlBar *urlLineEdit = new UrlBar; + QLineEdit *lineEdit = urlLineEdit->lineEdit(); + if (!m_lineEditCompleter && count() > 0) + { + HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); + completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel()); + m_lineEditCompleter = new QCompleter(completionModel, this); + // Should this be in Qt by default? + QAbstractItemView *popup = m_lineEditCompleter->popup(); + QListView *listView = qobject_cast(popup); + if (listView) + { + listView->setUniformItemSizes(true); + } + } + lineEdit->setCompleter(m_lineEditCompleter); + connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed())); + m_lineEdits->addWidget(urlLineEdit); + m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); + + // optimization to delay creating the more expensive WebView, history, etc + if (count() == 0) + { + QWidget *emptyWidget = new QWidget; + QPalette p = emptyWidget->palette(); + p.setColor(QPalette::Window, palette().color(QPalette::Base)); + emptyWidget->setPalette(p); + emptyWidget->setAutoFillBackground(true); + disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + addTab(emptyWidget, i18n("(Untitled)")); + connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + return 0; + } + + // webview + WebView *webView = new WebView; + urlLineEdit->setWebView(webView); + + connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); + connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); + connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); + connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); + connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); + connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), this, SIGNAL(geometryChangeRequested(const QRect &))); + connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); + connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); + connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); + + connect(webView, SIGNAL( ctrlTabPressed() ), this, SLOT( nextTab() ) ); + connect(webView, SIGNAL( shiftCtrlTabPressed() ), this, SLOT( previousTab() ) ); + + addTab(webView, i18n("(Untitled)") ); + if (makeCurrent) + setCurrentWidget(webView); + + // webview actions + for (int i = 0; i < m_webActionList.count(); ++i) + { + WebActionMapper *mapper = m_webActionList[i]; + mapper->addChild( new KAction( webView->page()->action( mapper->webAction() ) ) ); + } + + if (count() == 1) + currentChanged(currentIndex()); + emit tabsChanged(); + return webView; +} + + +void MainView::reloadAllTabs() +{ + for (int i = 0; i < count(); ++i) + { + QWidget *tabWidget = widget(i); + if (WebView *tab = qobject_cast(tabWidget)) + { + tab->reload(); + } + } +} + + +void MainView::lineEditReturnPressed() +{ + if (QLineEdit *lineEdit = qobject_cast(sender())) + { + emit loadPage(lineEdit->text()); + if (m_lineEdits->currentWidget() == lineEdit) + currentWebView()->setFocus(); + } +} + + +void MainView::windowCloseRequested() +{ + WebPage *webPage = qobject_cast(sender()); + WebView *webView = qobject_cast(webPage->view()); + int index = webViewIndex(webView); + if (index >= 0) + { + if (count() == 1) + webView->webPage()->mainWindow()->close(); + else + closeTab(index); + } +} + + +void MainView::closeOtherTabs(int index) +{ + if (-1 == index) + return; + for (int i = count() - 1; i > index; --i) + closeTab(i); + for (int i = index - 1; i >= 0; --i) + closeTab(i); +} + + +// When index is -1 index chooses the current tab +void MainView::cloneTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + WebView *tab = newTab(false); + tab->setUrl( webView(index)->url() ); +} + + +// When index is -1 index chooses the current tab +void MainView::closeTab(int index) +{ + if (index < 0) + index = currentIndex(); + if (index < 0 || index >= count()) + return; + + bool hasFocus = false; + if (WebView *tab = webView(index)) + { + if (tab->isModified()) + { + int risp = KMessageBox::questionYesNo( this , + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no() ); + if( risp == KMessageBox::No ) + return; + } + hasFocus = tab->hasFocus(); + + m_recentlyClosedTabsAction->setEnabled(true); + m_recentlyClosedTabs.prepend(tab->url()); + if (m_recentlyClosedTabs.size() >= MainView::m_recentlyClosedTabsSize) + m_recentlyClosedTabs.removeLast(); + } + QWidget *lineEdit = m_lineEdits->widget(index); + m_lineEdits->removeWidget(lineEdit); + lineEdit->deleteLater(); + QWidget *webView = widget(index); + removeTab(index); + webView->deleteLater(); + emit tabsChanged(); + if (hasFocus && count() > 0) + currentWebView()->setFocus(); + if (count() == 0) + emit lastTabClosed(); +} + + +void MainView::webViewLoadStarted() +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) + { + setTabIcon(index, KIcon("rekonq") ); + } +} + + +void MainView::webViewIconChanged() +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) + { + QIcon icon = BrowserApplication::instance()->icon(webView->url()); + setTabIcon(index, icon); + } +} + + +void MainView::webViewTitleChanged(const QString &title) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + setTabText(index, title); + } + if (currentIndex() == index) + emit setCurrentTitle(title); + BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); +} + + +void MainView::webViewUrlChanged(const QUrl &url) +{ + WebView *webView = qobject_cast(sender()); + int index = webViewIndex(webView); + if (-1 != index) { + m_tabBar->setTabData(index, url); + } + emit tabsChanged(); +} + + +void MainView::aboutToShowRecentTabsMenu() +{ + m_recentlyClosedTabsMenu->clear(); + for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) + { + KAction *action = new KAction(m_recentlyClosedTabsMenu); + action->setData(m_recentlyClosedTabs.at(i)); + QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); + action->setIcon(icon); + action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); + m_recentlyClosedTabsMenu->addAction(action); + } +} + + +void MainView::aboutToShowRecentTriggeredAction(QAction *action) +{ + KUrl url = action->data().toUrl(); + loadUrlInCurrentTab(url); +} + + +void MainView::mouseDoubleClickEvent(QMouseEvent *event) +{ + if ( !childAt(event->pos() ) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) + { + newTab(); + return; + } + QTabWidget::mouseDoubleClickEvent(event); +} + + +void MainView::contextMenuEvent(QContextMenuEvent *event) +{ + if (!childAt(event->pos())) { + m_tabBar->contextMenuRequested(event->pos()); + return; + } + QTabWidget::contextMenuEvent(event); +} + + +void MainView::mouseReleaseEvent(QMouseEvent *event) +{ + if (event->button() == Qt::MidButton && !childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) + { + KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + { + WebView *webView = newTab(); + webView->setUrl(url); + } + } +} + + +void MainView::loadUrlInCurrentTab(const KUrl &url) +{ + WebView *webView = currentWebView(); + if (webView) + { + webView->loadUrl(url); + webView->setFocus(); + } +} + + +void MainView::nextTab() +{ + int next = currentIndex() + 1; + if (next == count()) + next = 0; + setCurrentIndex(next); +} + + +void MainView::previousTab() +{ + int next = currentIndex() - 1; + if (next < 0) + next = count() - 1; + setCurrentIndex(next); +} + + +// ---------------------------------------------------------------------------------------------------------------------------- diff --git a/src/mainview.h b/src/mainview.h new file mode 100644 index 00000000..3ffeef32 --- /dev/null +++ b/src/mainview.h @@ -0,0 +1,178 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + + +#ifndef TABWIDGET_H +#define TABWIDGET_H + +// KDE Includes +#include + +// Qt Includes +#include + +class WebView; +/** + * A proxy object that connects a single browser action + * to one child webpage action at a time. + * + * Example usage: used to keep the main window stop action in sync with + * the current tabs webview's stop action. + */ +class WebActionMapper : public QObject +{ + Q_OBJECT + +public: + WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent); + QWebPage::WebAction webAction() const; + void addChild(KAction *action); + void updateCurrent(QWebPage *currentParent); + +private slots: + void rootTriggered(); + void childChanged(); + void rootDestroyed(); + void currentDestroyed(); + +private: + QWebPage *m_currentParent; + KAction *m_root; + QWebPage::WebAction m_webAction; +}; + + +// ---------------------------------------------------------------------------------------------------------------------------- + +// Local Includes +#include "tabbar.h" + +// KDE Includes +#include +#include +#include + +// Qt Includes +#include + +QT_BEGIN_NAMESPACE +class QCompleter; +class QMenu; +class QStackedWidget; +QT_END_NAMESPACE + +/** + * TabWidget that contains WebViews and a stack widget of associated line edits. + * + * Connects up the current tab's signals to this class's signal and uses WebActionMapper + * to proxy the actions. + */ +class MainView : public KTabWidget +{ + Q_OBJECT + +public: + MainView(QWidget *parent = 0); + ~MainView(); + + +signals: + // tab widget signals + void loadPage(const QString &url); + void tabsChanged(); + void lastTabClosed(); + + // current tab signals + void setCurrentTitle(const QString &url); + void showStatusBarMessage(const QString &message); + void linkHovered(const QString &link); + void loadProgress(int progress); + void geometryChangeRequested(const QRect &geometry); + void menuBarVisibilityChangeRequested(bool visible); + void statusBarVisibilityChangeRequested(bool visible); + void toolBarVisibilityChangeRequested(bool visible); + void printRequested(QWebFrame *frame); + +public: + void clear(); + void addWebAction(KAction *action, QWebPage::WebAction webAction); + + KAction *newTabAction() const; + KAction *closeTabAction() const; + KAction *recentlyClosedTabsAction() const; + KAction *nextTabAction() const; + KAction *previousTabAction() const; + + QWidget *lineEditStack() const; + QLineEdit *currentLineEdit() const; + WebView *currentWebView() const; + WebView *webView(int index) const; + QLineEdit *lineEdit(int index) const; + int webViewIndex(WebView *webView) const; + +protected: + void mouseDoubleClickEvent(QMouseEvent *event); + void contextMenuEvent(QContextMenuEvent *event); + void mouseReleaseEvent(QMouseEvent *event); + + +public slots: + void loadUrlInCurrentTab(const KUrl &url); + WebView *newTab(bool makeCurrent = true); + void cloneTab(int index = -1); + void closeTab(int index = -1); + void closeOtherTabs(int index); + void reloadTab(int index = -1); + void reloadAllTabs(); + void nextTab(); + void previousTab(); + +private slots: + void currentChanged(int index); + void aboutToShowRecentTabsMenu(); + void aboutToShowRecentTriggeredAction(QAction *action); // need QAction! + void webViewLoadStarted(); + void webViewIconChanged(); + void webViewTitleChanged(const QString &title); + void webViewUrlChanged(const QUrl &url); + void lineEditReturnPressed(); + void windowCloseRequested(); + void moveTab(int fromIndex, int toIndex); + +private: + KAction *m_recentlyClosedTabsAction; + KAction *m_newTabAction; + KAction *m_closeTabAction; + KAction *m_nextTabAction; + KAction *m_previousTabAction; + + KMenu *m_recentlyClosedTabsMenu; + static const int m_recentlyClosedTabsSize = 10; + QList m_recentlyClosedTabs; + QList m_webActionList; + + QCompleter *m_lineEditCompleter; + QStackedWidget *m_lineEdits; + TabBar *m_tabBar; +}; + +#endif // TABWIDGET_H + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9813cf1e..481bac96 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -21,13 +21,13 @@ // Self Includes #include "mainwindow.h" +#include "mainwindow.moc" // Local Includes #include "browserapplication.h" #include "downloadmanager.h" #include "history.h" #include "settings.h" -#include "tabwidget.h" #include "bookmarks.h" #include "webview.h" @@ -57,7 +57,7 @@ MainWindow::MainWindow() : KXmlGuiWindow() - , m_tabWidget( new TabWidget(this) ) + , m_tabWidget( new MainView(this) ) { // accept dnd setAcceptDrops(true); @@ -587,7 +587,7 @@ void MainWindow::loadPage(const QString &page) } -TabWidget *MainWindow::tabWidget() const +MainView *MainWindow::tabWidget() const { return m_tabWidget; } diff --git a/src/mainwindow.h b/src/mainwindow.h index aa8e3d65..8a13d7f9 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -25,6 +25,7 @@ // Local Includes #include "findbar.h" #include "searchbar.h" +#include "mainview.h" // KDE Includes #include @@ -37,7 +38,6 @@ class QWebFrame; -class TabWidget; class WebView; /** @@ -53,7 +53,7 @@ public: ~MainWindow(); static KUrl guessUrlFromString(const QString &url); - TabWidget *tabWidget() const; + MainView *tabWidget() const; WebView *currentTab() const; private: @@ -118,7 +118,7 @@ private: QString m_lastSearch; - TabWidget *m_tabWidget; + MainView *m_tabWidget; }; #endif // MAINWINDOW_H diff --git a/src/tabbar.cpp b/src/tabbar.cpp new file mode 100644 index 00000000..9aae3644 --- /dev/null +++ b/src/tabbar.cpp @@ -0,0 +1,207 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes +#include "tabbar.h" + +#include "browserapplication.h" +#include "mainwindow.h" +#include "history.h" +#include "urlbar.h" +#include "webview.h" + +// KDE Includes +#include +#include +#include +#include + +// Qt Includes +#include +#include + + +TabBar::TabBar(QWidget *parent) + : KTabBar(parent) +{ + setElideMode(Qt::ElideRight); + setContextMenuPolicy(Qt::CustomContextMenu); + setAcceptDrops(true); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); + + QString alt = QLatin1String("Alt+%1"); + for (int i = 1; i <= 10; ++i) + { + int key = i; + if (key == 10) + { + key = 0; + } + QShortcut *shortCut = new QShortcut(alt.arg(key), this); + m_tabShortcuts.append(shortCut); + connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); + } +} + + +TabBar::~TabBar() +{ +} + + +void TabBar::selectTabAction() +{ + if (QShortcut *shortCut = qobject_cast(sender())) + { + int index = m_tabShortcuts.indexOf(shortCut); + if (index == 0) + index = 10; + setCurrentIndex(index); + } +} + + +void TabBar::contextMenuRequested(const QPoint &position) +{ + // FIXME: use right actions + KMenu menu; + menu.addAction(i18n("New &Tab"), this, SIGNAL( newTab() ), QKeySequence::AddTab); + int index = tabAt(position); + if (-1 != index) + { + KAction *action = (KAction * ) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); + action->setData(index); + + menu.addSeparator(); + + action = (KAction * ) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); + action->setData(index); + + action = (KAction * ) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); + action->setData(index); + + menu.addSeparator(); + + action = (KAction * ) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); + action->setData(index); + } + else + { + menu.addSeparator(); + } + menu.addAction(i18n("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); + menu.exec(QCursor::pos()); +} + + +void TabBar::cloneTab() +{ + if (KAction *action = qobject_cast(sender())) + { + int index = action->data().toInt(); + emit cloneTab(index); + } +} + + +void TabBar::closeTab() +{ + if (KAction *action = qobject_cast(sender())) + { + int index = action->data().toInt(); + emit closeTab(index); + } +} + + +void TabBar::closeOtherTabs() +{ + if (KAction *action = qobject_cast(sender())) + { + int index = action->data().toInt(); + emit closeOtherTabs(index); + } +} + + +void TabBar::mousePressEvent(QMouseEvent *event) +{ + if (event->button() == Qt::LeftButton) + m_dragStartPos = event->pos(); + QTabBar::mousePressEvent(event); +} + + +void TabBar::mouseMoveEvent(QMouseEvent *event) +{ + if (event->buttons() == Qt::LeftButton && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) + { + QDrag *drag = new QDrag(this); + QMimeData *mimeData = new QMimeData; + QList urls; + int index = tabAt(event->pos()); + QUrl url = tabData(index).toUrl(); + urls.append(url); + mimeData->setUrls(urls); + mimeData->setText(tabText(index)); + mimeData->setData(QLatin1String("action"), "tab-reordering"); + drag->setMimeData(mimeData); + drag->exec(); + } + QTabBar::mouseMoveEvent(event); +} + + +void TabBar::dragEnterEvent(QDragEnterEvent *event) +{ + const QMimeData *mimeData = event->mimeData(); + QStringList formats = mimeData->formats(); + + if (formats.contains(QLatin1String("action")) && (mimeData->data(QLatin1String("action")) == "tab-reordering")) + { + event->acceptProposedAction(); + } + QTabBar::dragEnterEvent(event); +} + + +void TabBar::dropEvent(QDropEvent *event) +{ + int fromIndex = tabAt(m_dragStartPos); + int toIndex = tabAt(event->pos()); + if (fromIndex != toIndex) + { + emit tabMoveRequested(fromIndex, toIndex); + event->acceptProposedAction(); + } + QTabBar::dropEvent(event); +} + + +void TabBar::reloadTab() +{ + if (KAction *action = qobject_cast(sender())) + { + int index = action->data().toInt(); + emit reloadTab(index); + } +} + diff --git a/src/tabbar.h b/src/tabbar.h new file mode 100644 index 00000000..0692fcd6 --- /dev/null +++ b/src/tabbar.h @@ -0,0 +1,74 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + + +#ifndef TABBAR_H +#define TABBAR_H + +// KDE Includes +#include + +// Qt Includes +#include + +/** + * Tab bar with a few more features such as a context menu and shortcuts + */ +class TabBar : public KTabBar +{ + Q_OBJECT + +signals: + void newTab(); + void cloneTab(int index); + void closeTab(int index); + void closeOtherTabs(int index); + void reloadTab(int index); + void reloadAllTabs(); + void tabMoveRequested(int fromIndex, int toIndex); + +public: + TabBar(QWidget *parent = 0); + ~TabBar(); + +protected: + void mousePressEvent(QMouseEvent* event); + void mouseMoveEvent(QMouseEvent* event); + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + +private slots: + void selectTabAction(); + void cloneTab(); + void closeTab(); + void closeOtherTabs(); + void reloadTab(); + void contextMenuRequested(const QPoint &position); + +private: + QList m_tabShortcuts; + friend class MainView; + + QPoint m_dragStartPos; + int m_dragCurrentIndex; +}; + +#endif diff --git a/src/tabwidget.cpp b/src/tabwidget.cpp deleted file mode 100644 index 4af3ef60..00000000 --- a/src/tabwidget.cpp +++ /dev/null @@ -1,863 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -// Local Includes -#include "tabwidget.h" - -#include "browserapplication.h" -#include "mainwindow.h" -#include "history.h" -#include "urlbar.h" -#include "webview.h" - -// KDE Includes -#include -#include -#include - -// Qt Includes -#include -#include - - -TabBar::TabBar(QWidget *parent) - : KTabBar(parent) -{ - setElideMode(Qt::ElideRight); - setContextMenuPolicy(Qt::CustomContextMenu); - setAcceptDrops(true); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); - - QString alt = QLatin1String("Alt+%1"); - for (int i = 1; i <= 10; ++i) - { - int key = i; - if (key == 10) - key = 0; - QShortcut *shortCut = new QShortcut(alt.arg(key), this); - m_tabShortcuts.append(shortCut); - connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); - } -} - - -TabBar::~TabBar() -{ -} - - -void TabBar::selectTabAction() -{ - if (QShortcut *shortCut = qobject_cast(sender())) - { - int index = m_tabShortcuts.indexOf(shortCut); - if (index == 0) - index = 10; - setCurrentIndex(index); - } -} - - -void TabBar::contextMenuRequested(const QPoint &position) -{ - KMenu menu; - menu.addAction(i18n("New &Tab"), this, SIGNAL( newTab() ), QKeySequence::AddTab); - int index = tabAt(position); - if (-1 != index) - { - KAction *action = (KAction * ) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); - action->setData(index); - - menu.addSeparator(); - - action = (KAction * ) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); - action->setData(index); - - action = (KAction * ) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); - action->setData(index); - - menu.addSeparator(); - - action = (KAction * ) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); - action->setData(index); - } - else - { - menu.addSeparator(); - } - menu.addAction(i18n("Reload All Tabs"), this, SIGNAL(reloadAllTabs())); - menu.exec(QCursor::pos()); -} - - -void TabBar::cloneTab() -{ - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit cloneTab(index); - } -} - - -void TabBar::closeTab() -{ - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit closeTab(index); - } -} - - -void TabBar::closeOtherTabs() -{ - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit closeOtherTabs(index); - } -} - - -void TabBar::mousePressEvent(QMouseEvent *event) -{ - if (event->button() == Qt::LeftButton) - m_dragStartPos = event->pos(); - QTabBar::mousePressEvent(event); -} - - -void TabBar::mouseMoveEvent(QMouseEvent *event) -{ - if (event->buttons() == Qt::LeftButton && (event->pos() - m_dragStartPos).manhattanLength() > QApplication::startDragDistance()) - { - QDrag *drag = new QDrag(this); - QMimeData *mimeData = new QMimeData; - QList urls; - int index = tabAt(event->pos()); - QUrl url = tabData(index).toUrl(); - urls.append(url); - mimeData->setUrls(urls); - mimeData->setText(tabText(index)); - mimeData->setData(QLatin1String("action"), "tab-reordering"); - drag->setMimeData(mimeData); - drag->exec(); - } - QTabBar::mouseMoveEvent(event); -} - - -void TabBar::dragEnterEvent(QDragEnterEvent *event) -{ - const QMimeData *mimeData = event->mimeData(); - QStringList formats = mimeData->formats(); - - if (formats.contains(QLatin1String("action")) && (mimeData->data(QLatin1String("action")) == "tab-reordering")) - { - event->acceptProposedAction(); - } - QTabBar::dragEnterEvent(event); -} - - -void TabBar::dropEvent(QDropEvent *event) -{ - int fromIndex = tabAt(m_dragStartPos); - int toIndex = tabAt(event->pos()); - if (fromIndex != toIndex) - { - emit tabMoveRequested(fromIndex, toIndex); - event->acceptProposedAction(); - } - QTabBar::dropEvent(event); -} - - -void TabBar::reloadTab() -{ - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit reloadTab(index); - } -} - - -// --------------------------------------------------------------------------------------------------------------------------- - - -TabWidget::TabWidget(QWidget *parent) - : KTabWidget(parent) - , m_recentlyClosedTabsAction(0) - , m_newTabAction(0) - , m_closeTabAction(0) - , m_nextTabAction(0) - , m_previousTabAction(0) - , m_recentlyClosedTabsMenu(0) - , m_lineEditCompleter(0) - , m_lineEdits(0) - , m_tabBar(new TabBar(this)) -{ - setElideMode(Qt::ElideRight); - - connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); - connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); - connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); - connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); - connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); - connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); - connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); - setTabBar(m_tabBar); - - // Actions - m_newTabAction = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); - m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); - m_newTabAction->setIconVisibleInMenu(false); - connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); - - m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - m_closeTabAction->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); - m_closeTabAction->setIconVisibleInMenu(false); - connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); - - m_nextTabAction = new KAction(i18n("Show Next Tab"), this); - m_nextTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); - connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); - - m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); - m_previousTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); - connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); - - m_recentlyClosedTabsMenu = new KMenu(this); - connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); - connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); - m_recentlyClosedTabsAction = new KAction(i18n("Recently Closed Tabs"), this); - m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); - m_recentlyClosedTabsAction->setEnabled(false); - - // corner buttons - QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction(m_newTabAction); - addTabButton->setAutoRaise(true); - addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(addTabButton, Qt::TopLeftCorner); - - QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction(m_closeTabAction); - closeTabButton->setAutoRaise(true); - closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(closeTabButton, Qt::TopRightCorner); - - connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - - m_lineEdits = new QStackedWidget(this); -} - - -TabWidget::~TabWidget() -{ - delete m_lineEditCompleter; - delete m_recentlyClosedTabsMenu; -} - - -void TabWidget::clear() -{ - // clear the recently closed tabs - m_recentlyClosedTabs.clear(); - // clear the line edit history - for (int i = 0; i < m_lineEdits->count(); ++i) - { - QLineEdit *qLineEdit = lineEdit(i); - qLineEdit->setText(qLineEdit->text()); - } -} - - -void TabWidget::moveTab(int fromIndex, int toIndex) -{ - disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - - QWidget *tabWidget = widget(fromIndex); - QIcon icon = tabIcon(fromIndex); - QString text = tabText(fromIndex); - QVariant data = m_tabBar->tabData(fromIndex); - removeTab(fromIndex); - insertTab(toIndex, tabWidget, icon, text); - m_tabBar->setTabData(toIndex, data); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - setCurrentIndex(toIndex); -} - - -// When index is -1 index chooses the current tab -void TabWidget::reloadTab(int index) -{ - if (index < 0) - index = currentIndex(); - if (index < 0 || index >= count()) - return; - - QWidget *widget = this->widget(index); - if (WebView *tab = qobject_cast(widget)) - tab->reload(); -} - - -void TabWidget::addWebAction(KAction *action, QWebPage::WebAction webAction) -{ - if (!action) - return; - m_actions.append(new WebActionMapper(action, webAction, this)); -} - - -void TabWidget::currentChanged(int index) -{ - WebView *webView = this->webView(index); - if (!webView) - return; - - Q_ASSERT( m_lineEdits->count() == count() ); - - WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); - if (oldWebView) - { - disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); - disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); - disconnect(oldWebView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); - } - - connect(webView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); - connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); - connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); - - for (int i = 0; i < m_actions.count(); ++i) - { - WebActionMapper *mapper = m_actions[i]; - mapper->updateCurrent(webView->page()); - } - emit setCurrentTitle(webView->title()); - m_lineEdits->setCurrentIndex(index); - emit loadProgress(webView->progress()); - emit showStatusBarMessage(webView->lastStatusBarText()); - - // set focus to the current webview - webView->setFocus(); -} - - -KAction *TabWidget::newTabAction() const -{ - return m_newTabAction; -} - - -KAction *TabWidget::closeTabAction() const -{ - return m_closeTabAction; -} - - -KAction *TabWidget::recentlyClosedTabsAction() const -{ - return m_recentlyClosedTabsAction; -} - - -KAction *TabWidget::nextTabAction() const -{ - return m_nextTabAction; -} - - -KAction *TabWidget::previousTabAction() const -{ - return m_previousTabAction; -} - - -QWidget *TabWidget::lineEditStack() const -{ - return m_lineEdits; -} - - -QLineEdit *TabWidget::currentLineEdit() const -{ - return lineEdit(m_lineEdits->currentIndex()); -} - - -WebView *TabWidget::currentWebView() const -{ - return webView(currentIndex()); -} - - -QLineEdit *TabWidget::lineEdit(int index) const -{ - UrlBar *urlLineEdit = qobject_cast(m_lineEdits->widget(index)); - if (urlLineEdit) - return urlLineEdit->lineEdit(); - return 0; -} - - -WebView *TabWidget::webView(int index) const -{ - QWidget *widget = this->widget(index); - if (WebView *webView = qobject_cast(widget)) - { - return webView; - } - else - { - // optimization to delay creating the first webview - if (count() == 1) - { - TabWidget *that = const_cast(this); - that->setUpdatesEnabled(false); - that->newTab(); - that->closeTab(0); - that->setUpdatesEnabled(true); - return currentWebView(); - } - } - return 0; -} - - -int TabWidget::webViewIndex(WebView *webView) const -{ - int index = indexOf(webView); - return index; -} - - -WebView *TabWidget::newTab(bool makeCurrent) -{ - // line edit - UrlBar *urlLineEdit = new UrlBar; - QLineEdit *lineEdit = urlLineEdit->lineEdit(); - if (!m_lineEditCompleter && count() > 0) - { - HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); - completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel()); - m_lineEditCompleter = new QCompleter(completionModel, this); - // Should this be in Qt by default? - QAbstractItemView *popup = m_lineEditCompleter->popup(); - QListView *listView = qobject_cast(popup); - if (listView) - listView->setUniformItemSizes(true); - } - lineEdit->setCompleter(m_lineEditCompleter); - connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed())); - m_lineEdits->addWidget(urlLineEdit); - m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); - - // optimization to delay creating the more expensive WebView, history, etc - if (count() == 0) - { - QWidget *emptyWidget = new QWidget; - QPalette p = emptyWidget->palette(); - p.setColor(QPalette::Window, palette().color(QPalette::Base)); - emptyWidget->setPalette(p); - emptyWidget->setAutoFillBackground(true); - disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - addTab(emptyWidget, i18n("(Untitled)")); - connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - return 0; - } - - // webview - WebView *webView = new WebView; - urlLineEdit->setWebView(webView); - - connect(webView, SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted())); - connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(webViewIconChanged())); - connect(webView, SIGNAL(iconChanged()), this, SLOT(webViewIconChanged())); - connect(webView, SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &))); - connect(webView, SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &))); - connect(webView->page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested())); - connect(webView->page(), SIGNAL(geometryChangeRequested(const QRect &)), this, SIGNAL(geometryChangeRequested(const QRect &))); - connect(webView->page(), SIGNAL(printRequested(QWebFrame *)), this, SIGNAL(printRequested(QWebFrame *))); - connect(webView->page(), SIGNAL(menuBarVisibilityChangeRequested(bool)), this, SIGNAL(menuBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); - connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); - - connect(webView, SIGNAL( ctrlTabPressed() ), this, SLOT( nextTab() ) ); - connect(webView, SIGNAL( shiftCtrlTabPressed() ), this, SLOT( previousTab() ) ); - - addTab(webView, i18n("(Untitled)") ); - if (makeCurrent) - setCurrentWidget(webView); - - // webview actions - for (int i = 0; i < m_actions.count(); ++i) - { - WebActionMapper *mapper = m_actions[i]; - mapper->addChild( new KAction( webView->page()->action( mapper->webAction() ) ) ); - } - - if (count() == 1) - currentChanged(currentIndex()); - emit tabsChanged(); - return webView; -} - - -void TabWidget::reloadAllTabs() -{ - for (int i = 0; i < count(); ++i) - { - QWidget *tabWidget = widget(i); - if (WebView *tab = qobject_cast(tabWidget)) - { - tab->reload(); - } - } -} - - -void TabWidget::lineEditReturnPressed() -{ - if (QLineEdit *lineEdit = qobject_cast(sender())) - { - emit loadPage(lineEdit->text()); - if (m_lineEdits->currentWidget() == lineEdit) - currentWebView()->setFocus(); - } -} - - -void TabWidget::windowCloseRequested() -{ - WebPage *webPage = qobject_cast(sender()); - WebView *webView = qobject_cast(webPage->view()); - int index = webViewIndex(webView); - if (index >= 0) - { - if (count() == 1) - webView->webPage()->mainWindow()->close(); - else - closeTab(index); - } -} - - -void TabWidget::closeOtherTabs(int index) -{ - if (-1 == index) - return; - for (int i = count() - 1; i > index; --i) - closeTab(i); - for (int i = index - 1; i >= 0; --i) - closeTab(i); -} - - -// When index is -1 index chooses the current tab -void TabWidget::cloneTab(int index) -{ - if (index < 0) - index = currentIndex(); - if (index < 0 || index >= count()) - return; - WebView *tab = newTab(false); - tab->setUrl( webView(index)->url() ); -} - - -// When index is -1 index chooses the current tab -void TabWidget::closeTab(int index) -{ - if (index < 0) - index = currentIndex(); - if (index < 0 || index >= count()) - return; - - bool hasFocus = false; - if (WebView *tab = webView(index)) - { - if (tab->isModified()) - { - int risp = KMessageBox::questionYesNo( this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?"), - KStandardGuiItem::no() ); - if( risp == KMessageBox::No ) - return; - } - hasFocus = tab->hasFocus(); - - m_recentlyClosedTabsAction->setEnabled(true); - m_recentlyClosedTabs.prepend(tab->url()); - if (m_recentlyClosedTabs.size() >= TabWidget::m_recentlyClosedTabsSize) - m_recentlyClosedTabs.removeLast(); - } - QWidget *lineEdit = m_lineEdits->widget(index); - m_lineEdits->removeWidget(lineEdit); - lineEdit->deleteLater(); - QWidget *webView = widget(index); - removeTab(index); - webView->deleteLater(); - emit tabsChanged(); - if (hasFocus && count() > 0) - currentWebView()->setFocus(); - if (count() == 0) - emit lastTabClosed(); -} - - -void TabWidget::webViewLoadStarted() -{ - WebView *webView = qobject_cast(sender()); - int index = webViewIndex(webView); - if (-1 != index) - { - setTabIcon(index, KIcon("rekonq") ); - } -} - - -void TabWidget::webViewIconChanged() -{ - WebView *webView = qobject_cast(sender()); - int index = webViewIndex(webView); - if (-1 != index) - { - QIcon icon = BrowserApplication::instance()->icon(webView->url()); - setTabIcon(index, icon); - } -} - - -void TabWidget::webViewTitleChanged(const QString &title) -{ - WebView *webView = qobject_cast(sender()); - int index = webViewIndex(webView); - if (-1 != index) { - setTabText(index, title); - } - if (currentIndex() == index) - emit setCurrentTitle(title); - BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); -} - - -void TabWidget::webViewUrlChanged(const QUrl &url) -{ - WebView *webView = qobject_cast(sender()); - int index = webViewIndex(webView); - if (-1 != index) { - m_tabBar->setTabData(index, url); - } - emit tabsChanged(); -} - - -void TabWidget::aboutToShowRecentTabsMenu() -{ - m_recentlyClosedTabsMenu->clear(); - for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) - { - KAction *action = new KAction(m_recentlyClosedTabsMenu); - action->setData(m_recentlyClosedTabs.at(i)); - QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); - action->setIcon(icon); - action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); - m_recentlyClosedTabsMenu->addAction(action); - } -} - - -void TabWidget::aboutToShowRecentTriggeredAction(QAction *action) -{ - KUrl url = action->data().toUrl(); - loadUrlInCurrentTab(url); -} - - -void TabWidget::mouseDoubleClickEvent(QMouseEvent *event) -{ - if ( !childAt(event->pos() ) - // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) - { - newTab(); - return; - } - QTabWidget::mouseDoubleClickEvent(event); -} - - -void TabWidget::contextMenuEvent(QContextMenuEvent *event) -{ - if (!childAt(event->pos())) { - m_tabBar->contextMenuRequested(event->pos()); - return; - } - QTabWidget::contextMenuEvent(event); -} - - -void TabWidget::mouseReleaseEvent(QMouseEvent *event) -{ - if (event->button() == Qt::MidButton && !childAt(event->pos()) - // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) - { - KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) - { - WebView *webView = newTab(); - webView->setUrl(url); - } - } -} - - -void TabWidget::loadUrlInCurrentTab(const KUrl &url) -{ - WebView *webView = currentWebView(); - if (webView) - { - webView->loadUrl(url); - webView->setFocus(); - } -} - - -void TabWidget::nextTab() -{ - int next = currentIndex() + 1; - if (next == count()) - next = 0; - setCurrentIndex(next); -} - - -void TabWidget::previousTab() -{ - int next = currentIndex() - 1; - if (next < 0) - next = count() - 1; - setCurrentIndex(next); -} - - -// ---------------------------------------------------------------------------------------------------------------------------- - - -WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) - : QObject(parent) - , m_currentParent(0) - , m_root(root) - , m_webAction(webAction) -{ - if ( !m_root ) - { - return; - } - connect(m_root, SIGNAL( triggered() ), this, SLOT( rootTriggered() ) ); - connect(root, SIGNAL( destroyed(QObject *) ), this, SLOT( rootDestroyed() ) ); - - root->setEnabled(false); -} - - -void WebActionMapper::rootDestroyed() -{ - m_root = 0; -} - - -void WebActionMapper::currentDestroyed() -{ - updateCurrent(0); -} - - -void WebActionMapper::addChild(KAction *action) -{ - if ( !action ) - { - return; - } - connect(action, SIGNAL( changed() ), this, SLOT( childChanged() ) ); -} - -QWebPage::WebAction WebActionMapper::webAction() const -{ - return m_webAction; -} - - -void WebActionMapper::rootTriggered() -{ - if (m_currentParent) - { - KAction *gotoAction = new KAction( m_currentParent->action(m_webAction) ); - gotoAction->trigger(); - } -} - - -void WebActionMapper::childChanged() -{ - if (KAction *source = qobject_cast(sender())) - { - if (m_root - && m_currentParent - && source->parent() == m_currentParent) - { - m_root->setChecked(source->isChecked()); - m_root->setEnabled(source->isEnabled()); - } - } -} - - -void WebActionMapper::updateCurrent(QWebPage *currentParent) -{ - if (m_currentParent) - disconnect(m_currentParent, SIGNAL(destroyed(QObject *)), - this, SLOT(currentDestroyed())); - - m_currentParent = currentParent; - if (!m_root) - { - return; - } - if (!m_currentParent) - { - m_root->setEnabled(false); - m_root->setChecked(false); - return; - } - KAction *source = new KAction( m_currentParent->action(m_webAction) ); - m_root->setChecked(source->isChecked()); - m_root->setEnabled(source->isEnabled()); - connect(m_currentParent, SIGNAL( destroyed(QObject *) ), this, SLOT( currentDestroyed() ) ); -} diff --git a/src/tabwidget.h b/src/tabwidget.h deleted file mode 100644 index 4edba9b9..00000000 --- a/src/tabwidget.h +++ /dev/null @@ -1,218 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - - -#ifndef TABWIDGET_H -#define TABWIDGET_H - -#include -#include - -#include -/* - Tab bar with a few more features such as a context menu and shortcuts - */ -class TabBar : public KTabBar -{ - Q_OBJECT - -signals: - void newTab(); - void cloneTab(int index); - void closeTab(int index); - void closeOtherTabs(int index); - void reloadTab(int index); - void reloadAllTabs(); - void tabMoveRequested(int fromIndex, int toIndex); - -public: - TabBar(QWidget *parent = 0); - ~TabBar(); - -protected: - void mousePressEvent(QMouseEvent* event); - void mouseMoveEvent(QMouseEvent* event); - void dragEnterEvent(QDragEnterEvent *event); - void dropEvent(QDropEvent *event); - -private slots: - void selectTabAction(); - void cloneTab(); - void closeTab(); - void closeOtherTabs(); - void reloadTab(); - void contextMenuRequested(const QPoint &position); - -private: - QList m_tabShortcuts; - friend class TabWidget; - - QPoint m_dragStartPos; - int m_dragCurrentIndex; -}; - - -// ---------------------------------------------------------------------------------------------------------------------------- - - -#include - -class WebView; -/*! - A proxy object that connects a single browser action - to one child webpage action at a time. - - Example usage: used to keep the main window stop action in sync with - the current tabs webview's stop action. - */ -class WebActionMapper : public QObject -{ - Q_OBJECT - -public: - WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent); - QWebPage::WebAction webAction() const; - void addChild(KAction *action); - void updateCurrent(QWebPage *currentParent); - -private slots: - void rootTriggered(); - void childChanged(); - void rootDestroyed(); - void currentDestroyed(); - -private: - QWebPage *m_currentParent; - KAction *m_root; - QWebPage::WebAction m_webAction; -}; - - -// ---------------------------------------------------------------------------------------------------------------------------- - -// KDE Includes -#include -#include -#include - -// Qt Includes -#include - -QT_BEGIN_NAMESPACE -class QCompleter; -class QMenu; -class QStackedWidget; -QT_END_NAMESPACE -/*! - TabWidget that contains WebViews and a stack widget of associated line edits. - - Connects up the current tab's signals to this class's signal and uses WebActionMapper - to proxy the actions. - */ -class TabWidget : public KTabWidget -{ - Q_OBJECT - -signals: - // tab widget signals - void loadPage(const QString &url); - void tabsChanged(); - void lastTabClosed(); - - // current tab signals - void setCurrentTitle(const QString &url); - void showStatusBarMessage(const QString &message); - void linkHovered(const QString &link); - void loadProgress(int progress); - void geometryChangeRequested(const QRect &geometry); - void menuBarVisibilityChangeRequested(bool visible); - void statusBarVisibilityChangeRequested(bool visible); - void toolBarVisibilityChangeRequested(bool visible); - void printRequested(QWebFrame *frame); - -public: - TabWidget(QWidget *parent = 0); - ~TabWidget(); - - void clear(); - void addWebAction(KAction *action, QWebPage::WebAction webAction); - - KAction *newTabAction() const; - KAction *closeTabAction() const; - KAction *recentlyClosedTabsAction() const; - KAction *nextTabAction() const; - KAction *previousTabAction() const; - - QWidget *lineEditStack() const; - QLineEdit *currentLineEdit() const; - WebView *currentWebView() const; - WebView *webView(int index) const; - QLineEdit *lineEdit(int index) const; - int webViewIndex(WebView *webView) const; - -protected: - void mouseDoubleClickEvent(QMouseEvent *event); - void contextMenuEvent(QContextMenuEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - - -public slots: - void loadUrlInCurrentTab(const KUrl &url); - WebView *newTab(bool makeCurrent = true); - void cloneTab(int index = -1); - void closeTab(int index = -1); - void closeOtherTabs(int index); - void reloadTab(int index = -1); - void reloadAllTabs(); - void nextTab(); - void previousTab(); - -private slots: - void currentChanged(int index); - void aboutToShowRecentTabsMenu(); - void aboutToShowRecentTriggeredAction(QAction *action); // need QAction! - void webViewLoadStarted(); - void webViewIconChanged(); - void webViewTitleChanged(const QString &title); - void webViewUrlChanged(const QUrl &url); - void lineEditReturnPressed(); - void windowCloseRequested(); - void moveTab(int fromIndex, int toIndex); - -private: - KAction *m_recentlyClosedTabsAction; - KAction *m_newTabAction; - KAction *m_closeTabAction; - KAction *m_nextTabAction; - KAction *m_previousTabAction; - - KMenu *m_recentlyClosedTabsMenu; - static const int m_recentlyClosedTabsSize = 10; - QList m_recentlyClosedTabs; - QList m_actions; - - QCompleter *m_lineEditCompleter; - QStackedWidget *m_lineEdits; - TabBar *m_tabBar; -}; - -#endif // TABWIDGET_H - diff --git a/src/webview.cpp b/src/webview.cpp index e17a961a..96167816 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -21,10 +21,10 @@ #include "browserapplication.h" #include "mainwindow.h" +#include "mainview.h" #include "cookiejar.h" #include "downloadmanager.h" #include "networkaccessmanager.h" -#include "tabwidget.h" #include "webview.h" #include -- cgit v1.2.1 From 3118e255ecf417553a6750950da4cd4880a7a42c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 02:26:59 +0100 Subject: Last commit before loadPage REMOVAL.. .. --- src/mainwindow.cpp | 6 +++--- src/mainwindow.h | 59 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 481bac96..6d1ccf5d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -169,17 +169,17 @@ void MainWindow::setupActions() actionCollection()->addAction( i18n("private browsing"), a ); connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotPrivateBrowsing() ) ); - a = new KAction( KIcon("zoom-in"), i18n("&Enlarge font"), this ); + a = new KAction( KIcon("zoom-in"), i18n("&Enlarge Font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Plus) ); actionCollection()->addAction( QLatin1String("bigger font"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextBigger() ) ); - a = new KAction( KIcon("zoom-original"), i18n("&Normal font"), this ); + a = new KAction( KIcon("zoom-original"), i18n("&Normal Font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_0) ); actionCollection()->addAction( QLatin1String("normal font"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextNormal() ) ); - a = new KAction( KIcon("zoom-out"), i18n("&Shrink font"), this ); + a = new KAction( KIcon("zoom-out"), i18n("&Shrink Font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Minus) ); actionCollection()->addAction( QLatin1String("smaller font"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextSmaller() ) ); diff --git a/src/mainwindow.h b/src/mainwindow.h index 8a13d7f9..fb251657 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -40,10 +40,16 @@ class QWebFrame; class WebView; + /** - The MainWindow of the Browser Application. - Handles the tab widget and all the actions -*/ + * This class serves as the main window for rekonq. + * It handles the menus, toolbars, and status bars. + * + * @short Main window class + * @author Andrea Diamantini adjam7_AT_gmail_DOT_com + * + */ + class MainWindow : public KXmlGuiWindow { Q_OBJECT @@ -60,28 +66,42 @@ private: void setupActions(); void setupCustomMenu(); -public slots: +private slots: + void loadPage(const QString &url); void slotHome(); - void slotFind(const QString &); - void slotFindNext(); - void slotFindPrevious(); - -private slots: + void loadUrl(const KUrl &url); void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); void slotUpdateWindowTitle(const QString &title = QString()); + void slotOpenLocation(); + void slotAboutToShowBackMenu(); - void loadUrl(const KUrl &url); - void slotPreferences(); + // history related + void slotOpenActionUrl(QAction *action); + void slotOpenPrevious(); + void slotOpenNext(); + void slotShowWindow(); + void slotSwapFocus(); + void geometryChangeRequested(const QRect &geometry); + + + // File Menu slots void slotFileNew(); void slotFileOpen(); void slotFilePrintPreview(); void slotFilePrint(); void slotPrivateBrowsing(); void slotFileSaveAs(); + void printRequested(QWebFrame *frame); + // Edit Menu slots + void slotFind(const QString &); + void slotFindNext(); + void slotFindPrevious(); + + // View Menu slots void slotViewTextBigger(); void slotViewTextNormal(); void slotViewTextSmaller(); @@ -89,23 +109,12 @@ private slots: void slotViewFullScreen(bool enable); void slotViewFindBar(); + // Tools Menu slots void slotToggleInspector(bool enable); void slotDownloadManager(); - void slotOpenLocation(); - - void slotAboutToShowBackMenu(); - - // history related - void slotOpenActionUrl(QAction *action); - void slotOpenPrevious(); - void slotOpenNext(); - - void slotShowWindow(); - void slotSwapFocus(); - - void printRequested(QWebFrame *frame); - void geometryChangeRequested(const QRect &geometry); + // Settings Menu slots + void slotPreferences(); private: SearchBar *m_searchBar; -- cgit v1.2.1 From a14af0874d4ceac743727af1665ea1d5f15839d9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 02:44:50 +0100 Subject: removed LoadPage method to semplify API Now we have just loadUrl slot to run pages.. --- src/browserapplication.cpp | 9 +++++++-- src/mainview.cpp | 4 +++- src/mainview.h | 2 +- src/mainwindow.cpp | 41 +++++++++++++++-------------------------- src/mainwindow.h | 9 +++------ 5 files changed, 29 insertions(+), 36 deletions(-) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index bc29d64e..bb8c76b1 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -135,9 +135,14 @@ void BrowserApplication::postLaunch() KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int n = args->count(); if (n > 1) - mainWindow()->loadPage(args->arg(n-1)); + { + KUrl url = MainWindow::guessUrlFromString( args->arg(n-1) ); + mainWindow()->loadUrl( url ); + } else + { mainWindow()->slotHome(); + } } BrowserApplication::historyManager(); } @@ -272,7 +277,7 @@ bool BrowserApplication::isTheOnlyBrowser() const void BrowserApplication::openUrl(const KUrl &url) { - mainWindow()->loadPage( url.url() ); + mainWindow()->loadUrl( url ); } diff --git a/src/mainview.cpp b/src/mainview.cpp index 79cb865d..d4318cdf 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -477,9 +477,11 @@ void MainView::lineEditReturnPressed() { if (QLineEdit *lineEdit = qobject_cast(sender())) { - emit loadPage(lineEdit->text()); + emit loadUrlPage( KUrl( lineEdit->text() ) ); if (m_lineEdits->currentWidget() == lineEdit) + { currentWebView()->setFocus(); + } } } diff --git a/src/mainview.h b/src/mainview.h index 3ffeef32..0458611d 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -96,7 +96,7 @@ public: signals: // tab widget signals - void loadPage(const QString &url); + void loadUrlPage(const KUrl &url); void tabsChanged(); void lastTabClosed(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6d1ccf5d..b941e49b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -67,7 +67,7 @@ MainWindow::MainWindow() // tell the KXmlGuiWindow that this is indeed the main widget setCentralWidget(m_tabWidget); - connect(m_tabWidget, SIGNAL( loadPage(const QString &) ), this, SLOT( loadPage(const QString &) ) ); + connect(m_tabWidget, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); @@ -236,14 +236,9 @@ void MainWindow::setupCustomMenu() historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); historyMenu->setInitialActions(historyActions); - //-------------------------------------------------------------------------------------------------------------- - - // ------------------------------ BOOKMARKS MENU -------------------------------------------------------------- - - - // ------------------------------------------------------------------------------------------------------------- } + KUrl MainWindow::guessUrlFromString(const QString &string) { QString urlStr = string.trimmed(); @@ -301,7 +296,11 @@ KUrl MainWindow::guessUrlFromString(const QString &string) void MainWindow::loadUrl(const KUrl &url) { - loadPage( url.url() ); + if (!currentTab() || url.isEmpty()) + return; + + m_tabWidget->currentLineEdit()->setText( url.prettyUrl() ); + m_tabWidget->loadUrlInCurrentTab(url); } @@ -360,15 +359,16 @@ void MainWindow::slotFileNew() void MainWindow::slotFileOpen() { - QString file = KFileDialog::getOpenFileName( KUrl(), - i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), - this, - i18n("Open Web Resource") ); + QString filePath = KFileDialog::getOpenFileName( KUrl(), + i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), + this, + i18n("Open Web Resource") + ); - if (file.isEmpty()) + if (filePath.isEmpty()) return; - loadPage(file); + loadUrl( guessUrlFromString(filePath) ); } @@ -542,7 +542,7 @@ void MainWindow::slotHome() KConfig config("rekonqrc"); KConfigGroup group = config.group("Global Settings"); QString home = group.readEntry( QString("home"), QString("http://www.kde.org/") ); - loadPage(home); + loadUrl( KUrl(home) ); } @@ -576,17 +576,6 @@ void MainWindow::slotSwapFocus() } -void MainWindow::loadPage(const QString &page) -{ - if (!currentTab() || page.isEmpty()) - return; - - KUrl url = guessUrlFromString(page); - m_tabWidget->currentLineEdit()->setText( url.prettyUrl() ); - m_tabWidget->loadUrlInCurrentTab(url); -} - - MainView *MainWindow::tabWidget() const { return m_tabWidget; diff --git a/src/mainwindow.h b/src/mainwindow.h index fb251657..e34c799e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -45,9 +45,6 @@ class WebView; * This class serves as the main window for rekonq. * It handles the menus, toolbars, and status bars. * - * @short Main window class - * @author Andrea Diamantini adjam7_AT_gmail_DOT_com - * */ class MainWindow : public KXmlGuiWindow @@ -66,11 +63,11 @@ private: void setupActions(); void setupCustomMenu(); -private slots: - - void loadPage(const QString &url); +public slots: void slotHome(); void loadUrl(const KUrl &url); + +private slots: void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); void slotUpdateWindowTitle(const QString &title = QString()); -- cgit v1.2.1 From 5391120be8cfd3a5d752ac8c7b66bf17b690f303 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 12:10:19 +0100 Subject: BIG change!! Removed use of proxy webactionmapper to manage web actions.. --- src/mainview.cpp | 115 ++++++++++++++++++++++++++++++++++++++--------------- src/mainview.h | 17 ++++++-- src/mainwindow.cpp | 53 +++++++++++++++--------- src/rekonqui.rc | 3 +- 4 files changed, 133 insertions(+), 55 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index d4318cdf..f61a7593 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -19,9 +19,11 @@  * ============================================================ */ -// Local Includes +// Self Includes #include "mainview.h" +#include "mainview.moc" +// Local Includes #include "tabbar.h" #include "browserapplication.h" #include "mainwindow.h" @@ -212,6 +214,87 @@ MainView::~MainView() } +// ======================================================================================================== + KAction *MainView::newTabAction() const {return m_newTabAction; } + KAction *MainView::closeTabAction() const {return m_closeTabAction; } + KAction *MainView::recentlyClosedTabsAction() const {return m_recentlyClosedTabsAction;} + KAction *MainView::nextTabAction() const{} + KAction *MainView::previousTabAction() const{} + + void MainView::slotWebReload() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Reload); + action->trigger(); + } + + void MainView::slotWebBack() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Back); + action->trigger(); + } + + void MainView::slotWebForward() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Forward); + action->trigger(); + } + + void MainView::slotWebUndo() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Undo); + action->trigger(); + } + + void MainView::slotWebRedo() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Redo); + action->trigger(); + } + + void MainView::slotWebCut() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Cut); + action->trigger(); + } + + void MainView::slotWebCopy() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Copy); + action->trigger(); + } + + void MainView::slotWebPaste() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Paste); + action->trigger(); + } + + void MainView::slotWebSelectAll() + { + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + // FIXME + } + +// ======================================================================================================== + + void MainView::clear() { // clear the recently closed tabs @@ -298,36 +381,6 @@ void MainView::currentChanged(int index) } -KAction *MainView::newTabAction() const -{ - return m_newTabAction; -} - - -KAction *MainView::closeTabAction() const -{ - return m_closeTabAction; -} - - -KAction *MainView::recentlyClosedTabsAction() const -{ - return m_recentlyClosedTabsAction; -} - - -KAction *MainView::nextTabAction() const -{ - return m_nextTabAction; -} - - -KAction *MainView::previousTabAction() const -{ - return m_previousTabAction; -} - - QWidget *MainView::lineEditStack() const { return m_lineEdits; diff --git a/src/mainview.h b/src/mainview.h index 0458611d..135bad13 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -23,11 +23,10 @@ #ifndef TABWIDGET_H #define TABWIDGET_H -// KDE Includes -#include - // Qt Includes #include +// KDE Includes +#include class WebView; /** @@ -75,7 +74,6 @@ private: QT_BEGIN_NAMESPACE class QCompleter; -class QMenu; class QStackedWidget; QT_END_NAMESPACE @@ -145,6 +143,17 @@ public slots: void nextTab(); void previousTab(); + // WEB slot actions + void slotWebReload(); + void slotWebBack(); + void slotWebForward(); + void slotWebUndo(); + void slotWebRedo(); + void slotWebCut(); + void slotWebCopy(); + void slotWebPaste(); + void slotWebSelectAll(); + private slots: void currentChanged(int index); void aboutToShowRecentTabsMenu(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b941e49b..e85cd7b2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -137,15 +137,26 @@ void MainWindow::setupActions() KStandardAction::home( this, SLOT( slotHome() ), actionCollection() ); KStandardAction::preferences( this, SLOT( slotPreferences() ), actionCollection() ); - m_tabWidget->addWebAction( KStandardAction::redisplay( this, 0, actionCollection() ) , QWebPage::Reload ); - m_tabWidget->addWebAction( KStandardAction::back( this, 0, actionCollection() ) , QWebPage::Back ); - m_tabWidget->addWebAction( KStandardAction::forward( this, 0, actionCollection() ) , QWebPage::Forward ); - m_tabWidget->addWebAction( KStandardAction::undo( this , 0 , actionCollection() ) , QWebPage::Undo ); - m_tabWidget->addWebAction( KStandardAction::redo( this , 0 , actionCollection() ) , QWebPage::Redo ); - m_tabWidget->addWebAction( KStandardAction::cut( this , 0 , actionCollection() ) , QWebPage::Cut ); - m_tabWidget->addWebAction( KStandardAction::copy( this , 0 , actionCollection() ) , QWebPage::Copy ); - m_tabWidget->addWebAction( KStandardAction::paste( this , 0 , actionCollection() ) , QWebPage::Paste ); - m_tabWidget->addWebAction( KStandardAction::selectAll( this , 0 , actionCollection() ) , QWebPage::SelectEndOfDocument ); + // WEB Actions (NO KStandardActions..) + KStandardAction::redisplay( m_tabWidget, SLOT( slotWebReload() ), actionCollection() ); + KStandardAction::back( m_tabWidget, SLOT( slotWebBack() ), actionCollection() ); + KStandardAction::forward( m_tabWidget, SLOT( slotWebForward() ), actionCollection() ); + KStandardAction::undo( m_tabWidget, SLOT( slotWebUndo() ), actionCollection() ); + KStandardAction::redo( m_tabWidget, SLOT( slotWebRedo() ), actionCollection() ); + KStandardAction::cut( m_tabWidget, SLOT( slotWebCut() ), actionCollection() ); + KStandardAction::copy( m_tabWidget, SLOT( slotWebCopy() ), actionCollection() ); + KStandardAction::paste( m_tabWidget, SLOT( slotWebPaste() ), actionCollection() ); + KStandardAction::selectAll( m_tabWidget, SLOT( slotWebSelectAll() ), actionCollection() ); + +// m_tabWidget->addWebAction( KStandardAction::redisplay( this, 0, actionCollection() ) , QWebPage::Reload ); +// m_tabWidget->addWebAction( KStandardAction::back( this, 0, actionCollection() ) , QWebPage::Back ); +// m_tabWidget->addWebAction( KStandardAction::forward( this, 0, actionCollection() ) , QWebPage::Forward ); +// m_tabWidget->addWebAction( KStandardAction::undo( this , 0 , actionCollection() ) , QWebPage::Undo ); +// m_tabWidget->addWebAction( KStandardAction::redo( this , 0 , actionCollection() ) , QWebPage::Redo ); +// m_tabWidget->addWebAction( KStandardAction::cut( this , 0 , actionCollection() ) , QWebPage::Cut ); +// m_tabWidget->addWebAction( KStandardAction::copy( this , 0 , actionCollection() ) , QWebPage::Copy ); +// m_tabWidget->addWebAction( KStandardAction::paste( this , 0 , actionCollection() ) , QWebPage::Paste ); +// m_tabWidget->addWebAction( KStandardAction::selectAll( this , 0 , actionCollection() ) , QWebPage::SelectEndOfDocument ); // stop reload Action m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); @@ -197,15 +208,13 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("web inspector"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotToggleInspector(bool) ) ); + // BOOKMARKS MENU a = new KActionMenu( i18n("B&ookmarks"), this ); actionCollection()->addAction( QLatin1String("bookmarks"), a ); BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); a->setMenu( bookmarksMenu ); - // =================================================================================================================== - // =================================================================================================================== - // FIXME - + // history related actions KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); historyBack->setMenu(m_historyBackMenu); @@ -217,6 +226,10 @@ void MainWindow::setupActions() KAction *historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); connect(historyForward, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenNext() ) ); actionCollection()->addAction( QLatin1String("history forward"), historyForward ); + + // =================================================================================================================== + + } @@ -230,9 +243,8 @@ void MainWindow::setupCustomMenu() menuBar()->insertMenu( actionCollection()->action("bookmarks"), historyMenu); QList historyActions; - historyActions.append( actionCollection()->action("Back") ); - historyActions.append( actionCollection()->action("Forward") ); - historyActions.append( actionCollection()->action("Home") ); + historyActions.append( actionCollection()->action("history back") ); + historyActions.append( actionCollection()->action("history forward") ); historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); historyMenu->setInitialActions(historyActions); @@ -593,20 +605,23 @@ WebView *MainWindow::currentTab() const void MainWindow::slotLoadProgress(int progress) { QAction *stop = actionCollection()->action( "stop" ); - QAction *reload = actionCollection()->action(" redisplay" ); + QAction *reload = actionCollection()->action( "view_redisplay" ); if (progress < 100 && progress > 0) { disconnect( m_stopReload, SIGNAL( triggered( bool ) ), reload , SIGNAL( triggered(bool) ) ); m_stopReload->setIcon( KIcon( "process-stop" ) ); - connect(m_stopReload, SIGNAL( triggered(bool ) ), stop, SIGNAL( triggered(bool) ) ); m_stopReload->setToolTip( i18n("Stop loading the current page") ); + m_stopReload->setText( i18n("Stop") ); + connect(m_stopReload, SIGNAL( triggered(bool ) ), stop, SIGNAL( triggered(bool) ) ); } else { disconnect( m_stopReload, SIGNAL( triggered( bool ) ), stop , SIGNAL( triggered(bool ) ) ); m_stopReload->setIcon( KIcon( "view-refresh" ) ); - connect(m_stopReload, SIGNAL( triggered( bool ) ), reload, SIGNAL( triggered(bool) ) ); m_stopReload->setToolTip( i18n("Reload the current page") ); + m_stopReload->setText( i18n("Reload") ); + connect(m_stopReload, SIGNAL( triggered( bool ) ), reload, SIGNAL( triggered(bool) ) ); + } } diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 1022fb20..323e775b 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -37,6 +37,7 @@ &View + -- cgit v1.2.1 From 910f1cc073f95f2928cb29d87561f71a27513872 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 12:26:38 +0100 Subject: Removed WebActionMapper class! Now we are really starting to have adjam web browser.. --- src/mainview.cpp | 125 ++--------------------------------------------------- src/mainview.h | 44 ++----------------- src/mainwindow.cpp | 12 +---- 3 files changed, 8 insertions(+), 173 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index f61a7593..21c318ed 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -42,103 +42,6 @@ - -WebActionMapper::WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent) - : QObject(parent) - , m_currentParent(0) - , m_root(root) - , m_webAction(webAction) -{ - if ( !m_root ) - { - return; - } - connect(m_root, SIGNAL( triggered() ), this, SLOT( rootTriggered() ) ); - connect(root, SIGNAL( destroyed(QObject *) ), this, SLOT( rootDestroyed() ) ); - - root->setEnabled(false); -} - - -void WebActionMapper::rootDestroyed() -{ - m_root = 0; -} - - -void WebActionMapper::currentDestroyed() -{ - updateCurrent(0); -} - - -void WebActionMapper::addChild(KAction *action) -{ - if ( !action ) - { - return; - } - connect(action, SIGNAL( changed() ), this, SLOT( childChanged() ) ); -} - -QWebPage::WebAction WebActionMapper::webAction() const -{ - return m_webAction; -} - - -void WebActionMapper::rootTriggered() -{ - if (m_currentParent) - { - KAction *gotoAction = new KAction( m_currentParent->action(m_webAction) ); - gotoAction->trigger(); - } -} - - -void WebActionMapper::childChanged() -{ - if (KAction *source = qobject_cast(sender())) - { - if (m_root - && m_currentParent - && source->parent() == m_currentParent) - { - m_root->setChecked(source->isChecked()); - m_root->setEnabled(source->isEnabled()); - } - } -} - - -void WebActionMapper::updateCurrent(QWebPage *currentParent) -{ - if (m_currentParent) - disconnect(m_currentParent, SIGNAL(destroyed(QObject *)), - this, SLOT(currentDestroyed())); - - m_currentParent = currentParent; - if (!m_root) - { - return; - } - if (!m_currentParent) - { - m_root->setEnabled(false); - m_root->setChecked(false); - return; - } - KAction *source = new KAction( m_currentParent->action(m_webAction) ); - m_root->setChecked(source->isChecked()); - m_root->setEnabled(source->isEnabled()); - connect(m_currentParent, SIGNAL( destroyed(QObject *) ), this, SLOT( currentDestroyed() ) ); -} - - -// ---------------------------------------------------------------------------------------------------------- - - MainView::MainView(QWidget *parent) : KTabWidget(parent) , m_recentlyClosedTabsAction(0) @@ -338,14 +241,6 @@ void MainView::reloadTab(int index) } -void MainView::addWebAction(KAction *action, QWebPage::WebAction webAction) -{ - if (!action) - return; - m_webActionList.append(new WebActionMapper(action, webAction, this)); -} - - void MainView::currentChanged(int index) { WebView *webView = this->webView(index); @@ -366,11 +261,6 @@ void MainView::currentChanged(int index) connect(webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); connect(webView, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int))); - for (int i = 0; i < m_webActionList.count(); ++i) - { - WebActionMapper *mapper = m_webActionList[i]; - mapper->updateCurrent(webView->page()); - } emit setCurrentTitle(webView->title()); m_lineEdits->setCurrentIndex(index); emit loadProgress(webView->progress()); @@ -499,13 +389,6 @@ WebView *MainView::newTab(bool makeCurrent) if (makeCurrent) setCurrentWidget(webView); - // webview actions - for (int i = 0; i < m_webActionList.count(); ++i) - { - WebActionMapper *mapper = m_webActionList[i]; - mapper->addChild( new KAction( webView->page()->action( mapper->webAction() ) ) ); - } - if (count() == 1) currentChanged(currentIndex()); emit tabsChanged(); @@ -591,10 +474,10 @@ void MainView::closeTab(int index) if (tab->isModified()) { int risp = KMessageBox::questionYesNo( this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?"), - KStandardGuiItem::no() ); + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no() ); if( risp == KMessageBox::No ) return; } diff --git a/src/mainview.h b/src/mainview.h index 135bad13..9fdc24bd 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -2,7 +2,6 @@  *  * This file is a part of the rekonq project  * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * @@ -23,54 +22,19 @@ #ifndef TABWIDGET_H #define TABWIDGET_H -// Qt Includes -#include -// KDE Includes -#include - -class WebView; -/** - * A proxy object that connects a single browser action - * to one child webpage action at a time. - * - * Example usage: used to keep the main window stop action in sync with - * the current tabs webview's stop action. - */ -class WebActionMapper : public QObject -{ - Q_OBJECT - -public: - WebActionMapper(KAction *root, QWebPage::WebAction webAction, QObject *parent); - QWebPage::WebAction webAction() const; - void addChild(KAction *action); - void updateCurrent(QWebPage *currentParent); - -private slots: - void rootTriggered(); - void childChanged(); - void rootDestroyed(); - void currentDestroyed(); - -private: - QWebPage *m_currentParent; - KAction *m_root; - QWebPage::WebAction m_webAction; -}; - - -// ---------------------------------------------------------------------------------------------------------------------------- - // Local Includes #include "tabbar.h" +#include "webview.h" // KDE Includes #include #include #include +#include // Qt Includes #include +#include QT_BEGIN_NAMESPACE class QCompleter; @@ -111,7 +75,6 @@ signals: public: void clear(); - void addWebAction(KAction *action, QWebPage::WebAction webAction); KAction *newTabAction() const; KAction *closeTabAction() const; @@ -176,7 +139,6 @@ private: KMenu *m_recentlyClosedTabsMenu; static const int m_recentlyClosedTabsSize = 10; QList m_recentlyClosedTabs; - QList m_webActionList; QCompleter *m_lineEditCompleter; QStackedWidget *m_lineEdits; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e85cd7b2..e14f8611 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -148,16 +148,6 @@ void MainWindow::setupActions() KStandardAction::paste( m_tabWidget, SLOT( slotWebPaste() ), actionCollection() ); KStandardAction::selectAll( m_tabWidget, SLOT( slotWebSelectAll() ), actionCollection() ); -// m_tabWidget->addWebAction( KStandardAction::redisplay( this, 0, actionCollection() ) , QWebPage::Reload ); -// m_tabWidget->addWebAction( KStandardAction::back( this, 0, actionCollection() ) , QWebPage::Back ); -// m_tabWidget->addWebAction( KStandardAction::forward( this, 0, actionCollection() ) , QWebPage::Forward ); -// m_tabWidget->addWebAction( KStandardAction::undo( this , 0 , actionCollection() ) , QWebPage::Undo ); -// m_tabWidget->addWebAction( KStandardAction::redo( this , 0 , actionCollection() ) , QWebPage::Redo ); -// m_tabWidget->addWebAction( KStandardAction::cut( this , 0 , actionCollection() ) , QWebPage::Cut ); -// m_tabWidget->addWebAction( KStandardAction::copy( this , 0 , actionCollection() ) , QWebPage::Copy ); -// m_tabWidget->addWebAction( KStandardAction::paste( this , 0 , actionCollection() ) , QWebPage::Paste ); -// m_tabWidget->addWebAction( KStandardAction::selectAll( this , 0 , actionCollection() ) , QWebPage::SelectEndOfDocument ); - // stop reload Action m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); @@ -166,7 +156,7 @@ void MainWindow::setupActions() a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); actionCollection()->addAction( QLatin1String("stop"), a ); - m_tabWidget->addWebAction( a, QWebPage::Stop); +// FIXME m_tabWidget->addWebAction( a, QWebPage::Stop); a = new KAction( KIcon(), i18n("Open Location"), this); actionCollection()->addAction( QLatin1String("open location"), a ); -- cgit v1.2.1 From 886bdb99cd998c045e111a2d7e6f77e29d30b784 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 9 Jan 2009 16:37:41 +0100 Subject: Every action is now in ActionCollection!! Fully adopted xmlgui && mainview concepts.. --- src/mainview.cpp | 182 +++++++++++++++++++++++------------------------------ src/mainview.h | 8 --- src/mainwindow.cpp | 49 ++++++++++++--- src/mainwindow.h | 1 + 4 files changed, 120 insertions(+), 120 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index 21c318ed..d796035e 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -35,6 +35,7 @@ #include #include #include +#include // Qt Includes #include @@ -45,10 +46,6 @@ MainView::MainView(QWidget *parent) : KTabWidget(parent) , m_recentlyClosedTabsAction(0) - , m_newTabAction(0) - , m_closeTabAction(0) - , m_nextTabAction(0) - , m_previousTabAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) , m_lineEdits(0) @@ -65,25 +62,7 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); setTabBar(m_tabBar); - // Actions - m_newTabAction = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); - m_newTabAction->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); - m_newTabAction->setIconVisibleInMenu(false); - connect(m_newTabAction, SIGNAL(triggered()), this, SLOT(newTab())); - - m_closeTabAction = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - m_closeTabAction->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); - m_closeTabAction->setIconVisibleInMenu(false); - connect(m_closeTabAction, SIGNAL(triggered()), this, SLOT(closeTab())); - - m_nextTabAction = new KAction(i18n("Show Next Tab"), this); - m_nextTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); - connect(m_nextTabAction, SIGNAL(triggered()), this, SLOT(nextTab())); - - m_previousTabAction = new KAction(i18n("Show Previous Tab"), this); - m_previousTabAction->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); - connect(m_previousTabAction, SIGNAL(triggered()), this, SLOT(previousTab())); - + // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); connect(m_recentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu())); connect(m_recentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *))); @@ -91,19 +70,7 @@ MainView::MainView(QWidget *parent) m_recentlyClosedTabsAction->setMenu(m_recentlyClosedTabsMenu); m_recentlyClosedTabsAction->setEnabled(false); - // corner buttons - QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction(m_newTabAction); - addTabButton->setAutoRaise(true); - addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(addTabButton, Qt::TopLeftCorner); - - QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction(m_closeTabAction); - closeTabButton->setAutoRaise(true); - closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - setCornerWidget(closeTabButton, Qt::TopRightCorner); - + // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); m_lineEdits = new QStackedWidget(this); @@ -117,85 +84,90 @@ MainView::~MainView() } -// ======================================================================================================== - KAction *MainView::newTabAction() const {return m_newTabAction; } - KAction *MainView::closeTabAction() const {return m_closeTabAction; } - KAction *MainView::recentlyClosedTabsAction() const {return m_recentlyClosedTabsAction;} - KAction *MainView::nextTabAction() const{} - KAction *MainView::previousTabAction() const{} +KAction *MainView::recentlyClosedTabsAction() const +{ + return m_recentlyClosedTabsAction; +} - void MainView::slotWebReload() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Reload); - action->trigger(); - } - void MainView::slotWebBack() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Back); - action->trigger(); - } +void MainView::slotWebReload() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Reload); + action->trigger(); +} - void MainView::slotWebForward() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Forward); - action->trigger(); - } - void MainView::slotWebUndo() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Undo); - action->trigger(); - } +void MainView::slotWebBack() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Back); + action->trigger(); +} - void MainView::slotWebRedo() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Redo); - action->trigger(); - } - void MainView::slotWebCut() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Cut); - action->trigger(); - } +void MainView::slotWebForward() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Forward); + action->trigger(); +} - void MainView::slotWebCopy() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Copy); - action->trigger(); - } - void MainView::slotWebPaste() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - QAction *action = currentParent->action(QWebPage::Paste); - action->trigger(); - } +void MainView::slotWebUndo() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Undo); + action->trigger(); +} - void MainView::slotWebSelectAll() - { - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - // FIXME - } -// ======================================================================================================== +void MainView::slotWebRedo() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Redo); + action->trigger(); +} + + +void MainView::slotWebCut() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Cut); + action->trigger(); +} + + +void MainView::slotWebCopy() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Copy); + action->trigger(); +} + + +void MainView::slotWebPaste() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Paste); + action->trigger(); +} + + +void MainView::slotWebSelectAll() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + // FIXME +} void MainView::clear() diff --git a/src/mainview.h b/src/mainview.h index 9fdc24bd..fa5c805f 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -76,11 +76,7 @@ signals: public: void clear(); - KAction *newTabAction() const; - KAction *closeTabAction() const; KAction *recentlyClosedTabsAction() const; - KAction *nextTabAction() const; - KAction *previousTabAction() const; QWidget *lineEditStack() const; QLineEdit *currentLineEdit() const; @@ -131,10 +127,6 @@ private slots: private: KAction *m_recentlyClosedTabsAction; - KAction *m_newTabAction; - KAction *m_closeTabAction; - KAction *m_nextTabAction; - KAction *m_previousTabAction; KMenu *m_recentlyClosedTabsMenu; static const int m_recentlyClosedTabsSize = 10; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e14f8611..6fcdf7e6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -99,6 +99,9 @@ MainWindow::MainWindow() // setup history & bookmarks menus setupCustomMenu(); + // setup Tab Bar + setupTabBar(); + // setting up custom widgets.. KToolBar *navigationBar = toolBar( "mainToolBar" ); navigationBar->addWidget( m_tabWidget->lineEditStack() ); @@ -152,7 +155,7 @@ void MainWindow::setupActions() m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); - // Custom Actions + // ============== Custom Actions a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); actionCollection()->addAction( QLatin1String("stop"), a ); @@ -162,9 +165,6 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("open location"), a ); connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotOpenLocation() ) ); - actionCollection()->addAction( QLatin1String("new tab"), m_tabWidget->newTabAction() ); - actionCollection()->addAction( QLatin1String("close tab"), m_tabWidget->closeTabAction() ); - a = new KAction( i18n("Private &Browsing..."), this ); a->setCheckable(true); actionCollection()->addAction( i18n("private browsing"), a ); @@ -198,13 +198,13 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("web inspector"), a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotToggleInspector(bool) ) ); - // BOOKMARKS MENU + // ================== BOOKMARKS MENU a = new KActionMenu( i18n("B&ookmarks"), this ); actionCollection()->addAction( QLatin1String("bookmarks"), a ); BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); a->setMenu( bookmarksMenu ); - // history related actions + // ================ history related actions KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); historyBack->setMenu(m_historyBackMenu); @@ -217,9 +217,44 @@ void MainWindow::setupActions() connect(historyForward, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenNext() ) ); actionCollection()->addAction( QLatin1String("history forward"), historyForward ); - // =================================================================================================================== + // =================== Tab Actions + a = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); + a->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); + actionCollection()->addAction( QLatin1String("new tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(newTab())); + + a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); + a->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); + actionCollection()->addAction( QLatin1String("close tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(closeTab())); + + a = new KAction(i18n("Show Next Tab"), this); + a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); + actionCollection()->addAction( QLatin1String("show next tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(nextTab())); + a = new KAction(i18n("Show Previous Tab"), this); + a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); + actionCollection()->addAction( QLatin1String("show prev tab"), a); + connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(previousTab())); +} + + +void MainWindow::setupTabBar() +{ + // Left corner button + QToolButton *addTabButton = new QToolButton(this); + addTabButton->setDefaultAction( actionCollection()->action("new tab") ); + addTabButton->setAutoRaise(true); + addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + m_tabWidget->setCornerWidget(addTabButton, Qt::TopLeftCorner); + // right corner button + QToolButton *closeTabButton = new QToolButton(this); + closeTabButton->setDefaultAction( actionCollection()->action("close tab") ); + closeTabButton->setAutoRaise(true); + closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + m_tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); } diff --git a/src/mainwindow.h b/src/mainwindow.h index e34c799e..fd7f13d6 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -62,6 +62,7 @@ public: private: void setupActions(); void setupCustomMenu(); + void setupTabBar(); public slots: void slotHome(); -- cgit v1.2.1 From 8b0c34007ddf70de767b036a21d978befb9654d4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 12 Jan 2009 01:10:49 +0100 Subject: Fixed unconnected STOP web action --- src/mainview.cpp | 9 +++++++++ src/mainview.h | 1 + src/mainwindow.cpp | 36 ++++++++++++++++++------------------ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index d796035e..4236d5d0 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -99,6 +99,15 @@ void MainView::slotWebReload() } +void MainView::slotWebStop() +{ + WebView *webView = currentWebView(); + QWebPage *currentParent = webView->webPage(); + QAction *action = currentParent->action(QWebPage::Stop); + action->trigger(); +} + + void MainView::slotWebBack() { WebView *webView = currentWebView(); diff --git a/src/mainview.h b/src/mainview.h index fa5c805f..1bb0bf6e 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -104,6 +104,7 @@ public slots: // WEB slot actions void slotWebReload(); + void slotWebStop(); void slotWebBack(); void slotWebForward(); void slotWebUndo(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6fcdf7e6..2086ff81 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -151,16 +151,16 @@ void MainWindow::setupActions() KStandardAction::paste( m_tabWidget, SLOT( slotWebPaste() ), actionCollection() ); KStandardAction::selectAll( m_tabWidget, SLOT( slotWebSelectAll() ), actionCollection() ); + a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); + a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); + actionCollection()->addAction( QLatin1String("stop"), a ); + connect( a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT( slotWebStop() ) ); + // stop reload Action m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); - // ============== Custom Actions - a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); - actionCollection()->addAction( QLatin1String("stop"), a ); -// FIXME m_tabWidget->addWebAction( a, QWebPage::Stop); - + // ============== Custom Actions a = new KAction( KIcon(), i18n("Open Location"), this); actionCollection()->addAction( QLatin1String("open location"), a ); connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotOpenLocation() ) ); @@ -173,30 +173,30 @@ void MainWindow::setupActions() a = new KAction( KIcon("zoom-in"), i18n("&Enlarge Font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Plus) ); actionCollection()->addAction( QLatin1String("bigger font"), a ); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextBigger() ) ); + connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextBigger() ) ); a = new KAction( KIcon("zoom-original"), i18n("&Normal Font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_0) ); actionCollection()->addAction( QLatin1String("normal font"), a ); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextNormal() ) ); + connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextNormal() ) ); a = new KAction( KIcon("zoom-out"), i18n("&Shrink Font"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Minus) ); actionCollection()->addAction( QLatin1String("smaller font"), a ); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewTextSmaller() ) ); + connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextSmaller() ) ); a = new KAction( i18n("Page S&ource"), this ); actionCollection()->addAction( QLatin1String("page source"), a ); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotViewPageSource() ) ); + connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewPageSource() ) ); a = new KAction( KIcon( "kget" ), i18n("Downloads"), this ); actionCollection()->addAction( QLatin1String("downloads"), a); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotDownloadManager() ) ); + connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotDownloadManager() ) ); a = new KAction( KIcon("page-zoom"), i18n("Enable Web &Inspector"), this ); a->setCheckable(true); actionCollection()->addAction( QLatin1String("web inspector"), a ); - connect( a, SIGNAL( triggered( bool ) ), this, SLOT( slotToggleInspector(bool) ) ); + connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotToggleInspector(bool) ) ); // ================== BOOKMARKS MENU a = new KActionMenu( i18n("B&ookmarks"), this ); @@ -208,35 +208,35 @@ void MainWindow::setupActions() KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); historyBack->setMenu(m_historyBackMenu); - connect(historyBack, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenPrevious() ) ); + connect(historyBack, SIGNAL( triggered(bool) ), this, SLOT( slotOpenPrevious() ) ); connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); actionCollection()->addAction( QLatin1String("history back"), historyBack); KAction *historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); - connect(historyForward, SIGNAL( triggered( bool ) ), this, SLOT( slotOpenNext() ) ); + connect(historyForward, SIGNAL( triggered(bool) ), this, SLOT( slotOpenNext() ) ); actionCollection()->addAction( QLatin1String("history forward"), historyForward ); // =================== Tab Actions a = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); actionCollection()->addAction( QLatin1String("new tab"), a); - connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(newTab())); + connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(newTab())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); a->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); actionCollection()->addAction( QLatin1String("close tab"), a); - connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(closeTab())); + connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(closeTab())); a = new KAction(i18n("Show Next Tab"), this); a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); actionCollection()->addAction( QLatin1String("show next tab"), a); - connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(nextTab())); + connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); actionCollection()->addAction( QLatin1String("show prev tab"), a); - connect(a, SIGNAL(triggered()), m_tabWidget, SLOT(previousTab())); + connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(previousTab())); } -- cgit v1.2.1 From 1e222f437c3e521dc1930b31680a437cc329a078 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 15 Jan 2009 01:01:32 +0100 Subject: - cmake 2.6.2 - changed web inspector icon --- CMakeLists.txt | 3 ++- src/mainwindow.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70606704..d9ef464d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,12 +18,13 @@ SET(REKONQ_VERSION_STRING # ================================================================================================= # minimum cmake required -CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.2) # ================================================================================================= SET(QT_MIN_VERSION 4.4.0) +FIND_PACKAGE(Qt4 REQUIRED) FIND_PACKAGE(KDE4 REQUIRED) INCLUDE(MacroOptionalFindPackage) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2086ff81..d1f60b5d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -193,7 +193,7 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("downloads"), a); connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotDownloadManager() ) ); - a = new KAction( KIcon("page-zoom"), i18n("Enable Web &Inspector"), this ); + a = new KAction( KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this ); a->setCheckable(true); actionCollection()->addAction( QLatin1String("web inspector"), a ); connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotToggleInspector(bool) ) ); -- cgit v1.2.1 From 694cbe620e7272deba4e051933df13f8250dd34b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 16 Jan 2009 11:46:45 +0100 Subject: Some moc adds and webview fixing.. --- src/history.cpp | 4 +++- src/tabbar.cpp | 5 +++-- src/webview.cpp | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/history.cpp b/src/history.cpp index 12a9d57f..dedabfdd 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -18,9 +18,11 @@  *  * ============================================================ */ -// Local Includes +// Self Includes #include "history.h" +#include "history.moc" +// Local Includes #include "autosaver.h" #include "browserapplication.h" diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 9aae3644..bf63db03 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -18,10 +18,11 @@  *  * ============================================================ */ - -// Local Includes +//Self Includes #include "tabbar.h" +#include "tabbar.moc" +// Local Includes #include "browserapplication.h" #include "mainwindow.h" #include "history.h" diff --git a/src/webview.cpp b/src/webview.cpp index 96167816..62acbba6 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -189,12 +190,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) KMenu menu(this); KAction *a = new KAction( KIcon("tab-new"), i18n("Open in New Tab"), this); connect( a, SIGNAL( triggered() ), this , SLOT( openLinkInNewTab() ) ); - menu.addAction( a ); + menu.addAction(a); menu.addSeparator(); - menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); + menu.addAction( pageAction(QWebPage::DownloadLinkToDisk) ); // Add link to bookmarks... menu.addSeparator(); - menu.addAction(pageAction(QWebPage::CopyLinkToClipboard)); + menu.addAction( pageAction(QWebPage::CopyLinkToClipboard) ); if ( page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled) ) { menu.addAction(pageAction(QWebPage::InspectElement)); @@ -298,7 +299,16 @@ void WebView::setStatusBarText(const QString &string) void WebView::downloadRequested(const QNetworkRequest &request) { - BrowserApplication::downloadManager()->download(request); +// BrowserApplication::downloadManager()->download(request); + + // FIXME --- FIXME --- FIXME --- FIXME --- FIXME + const KUrl url = KUrl( request.url() ); + + KConfig config("rekonqrc"); + KConfigGroup group1 = config.group("Global Settings"); + QString path = group1.readEntry(QString("downloadDirectory")) + QString("/") + url.fileName(); + + KIO::NetAccess::download( url , path , this ); } -- cgit v1.2.1 From 195641eb0e7972b32756e95340ebd48c21a7feaf Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 18 Jan 2009 02:10:22 +0100 Subject: Partially ported rekonq to KConfigXT technology.. Perhaps ~50%..going on!! --- src/CMakeLists.txt | 9 +- src/browserapplication.cpp | 46 +---- src/browserapplication.h | 2 +- src/findbar.cpp | 2 +- src/mainview.cpp | 5 +- src/mainwindow.cpp | 105 +++++++++- src/mainwindow.h | 4 + src/rekonq.kcfg | 73 +++++++ src/rekonq.kcfgc | 5 + src/rekonqui.rc | 14 +- src/settings.cpp | 472 +++++++++++++++++++++++---------------------- src/settings.h | 14 +- src/settings_appearance.ui | 98 ---------- src/settings_fonts.ui | 64 ++++++ src/settings_general.ui | 39 ++-- src/settings_privacy.ui | 23 ++- src/settings_proxy.ui | 15 +- src/webview.cpp | 4 +- 18 files changed, 539 insertions(+), 455 deletions(-) create mode 100644 src/rekonq.kcfg create mode 100644 src/rekonq.kcfgc delete mode 100644 src/settings_appearance.ui create mode 100644 src/settings_fonts.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 83297551..25c8e3cb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,12 +30,14 @@ KDE4_ADD_UI_FILES( rekonq_SRCS passworddialog.ui proxy.ui settings_general.ui - settings_appearance.ui + settings_fonts.ui settings_privacy.ui settings_proxy.ui ) -# include(${QT_USE_FILE}) +KDE4_ADD_KCFG_FILES( rekonq_SRCS rekonq.kcfgc ) + +### ------------------------------------------ ADD_DEFINITIONS( ${KDE4_DEFINITIONS} ) @@ -47,12 +49,11 @@ TARGET_LINK_LIBRARIES( rekonq ${QT_QTWEBKIT_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} -# ${QT_QTUITOOLS_LIBRARY} ) INSTALL( TARGETS rekonq ${INSTALL_TARGETS_DEFAULT_ARGS} ) ########### install files ############### -#INSTALL( FILES rekonq.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) +INSTALL( FILES rekonq.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) INSTALL( FILES rekonqui.rc DESTINATION ${DATA_INSTALL_DIR}/rekonq ) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index bb8c76b1..bbd4b8b1 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -127,8 +127,6 @@ void BrowserApplication::postLaunch() } QWebSettings::setIconDatabasePath(directory); - loadSettings(); - // newMainWindow() needs to be called in main() for this to happen if (m_mainWindows.count() > 0) { @@ -148,36 +146,6 @@ void BrowserApplication::postLaunch() } - -void BrowserApplication::loadSettings() -{ - KConfig config("rekonqrc"); - KConfigGroup group = config.group("Appearance Settings"); - - QWebSettings *defaultSettings = QWebSettings::globalSettings(); - QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); - int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); - QFont standardFont = QFont(standardFontFamily, standardFontSize); - standardFont = qVariantValue( group.readEntry( QString("standardFont"), standardFont ) ); - - defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); - defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); - - QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); - int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); - QFont fixedFont = QFont(fixedFontFamily, fixedFontSize); - fixedFont = qVariantValue(group.readEntry( QString("fixedFont"), fixedFont ) ); - - defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); - defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); - - defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, group.readEntry( QString("enableJavascript"), true ) ); - defaultSettings->setAttribute(QWebSettings::PluginsEnabled, group.readEntry( QString("enablePlugins"), true ) ); -} - - - - QList BrowserApplication::mainWindows() { clean(); @@ -190,8 +158,6 @@ QList BrowserApplication::mainWindows() } - - void BrowserApplication::clean() { // cleanup any deleted main windows first @@ -311,17 +277,7 @@ void BrowserApplication::newLocalSocketConnection() stream >> url; if (!url.isEmpty()) { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("Global Settings"); - int openLinksIn = group.readEntry( QString("openLinksIn"), QString().toInt() ); - if (openLinksIn == 1) - { - newMainWindow(); - } - else - { - mainWindow()->tabWidget()->newTab(); - } + mainWindow()->tabWidget()->newTab(); openUrl(url); } delete socket; diff --git a/src/browserapplication.h b/src/browserapplication.h index 8d33883e..4ec2cca6 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -49,7 +49,7 @@ public: BrowserApplication(KCmdLineArgs*, const QString &); ~BrowserApplication(); static BrowserApplication *instance(); - void loadSettings(); +// void loadSettings(); bool isTheOnlyBrowser() const; MainWindow *mainWindow(); diff --git a/src/findbar.cpp b/src/findbar.cpp index a1c867c2..6ba310ca 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -34,7 +34,7 @@ FindBar::FindBar(KXmlGuiWindow *parent) - : KToolBar( "Find Bar" , parent, Qt::BottomToolBarArea, true, false, false) + : KToolBar( "findBar" , parent, Qt::BottomToolBarArea, true, false, false) , m_lineEdit(0) { KAction *close = new KAction(KIcon("dialog-close") , "close" , this); diff --git a/src/mainview.cpp b/src/mainview.cpp index 4236d5d0..328d3dd1 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -175,7 +175,7 @@ void MainView::slotWebSelectAll() { WebView *webView = currentWebView(); QWebPage *currentParent = webView->webPage(); - // FIXME + // TODO } @@ -618,6 +618,3 @@ void MainView::previousTab() next = count() - 1; setCurrentIndex(next); } - - -// ---------------------------------------------------------------------------------------------------------------------------- diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d1f60b5d..6c177103 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -23,11 +23,14 @@ #include "mainwindow.h" #include "mainwindow.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "browserapplication.h" #include "downloadmanager.h" -#include "history.h" #include "settings.h" +#include "history.h" #include "bookmarks.h" #include "webview.h" @@ -62,17 +65,21 @@ MainWindow::MainWindow() // accept dnd setAcceptDrops(true); + // updating rekonq configuration + updateConfiguration(); + + // creating a new tab m_tabWidget->newTab(); // tell the KXmlGuiWindow that this is indeed the main widget setCentralWidget(m_tabWidget); + // connect signals and slots connect(m_tabWidget, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); -// connect(m_tabWidget, SIGNAL( tabsChanged()), m_autoSaver, SLOT( changeOccurred() ) ); connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); @@ -80,8 +87,6 @@ MainWindow::MainWindow() connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); slotUpdateWindowTitle(); -// -------------------------------------------------------------------------------------------------------------------------------- - // then, setup our actions setupActions(); @@ -276,6 +281,93 @@ void MainWindow::setupCustomMenu() } +// TODO FIXME +void MainWindow::updateConfiguration() +{ + // ============== General ================== + m_homePage = ReKonfig::homePage(); + +// int historyExpire = ReKonfig::expireHistory(); +// int days; +// switch (historyExpire) +// { +// case 0: days = 1; break; +// case 1: days = 7; break; +// case 2: days = 14; break; +// case 3: days = 30; break; +// case 4: days = 365; break; +// case 5: days = -1; break; +// default: days = -1; +// } +// m_historyExpire = days; +// +// m_downloadDir = ReKonfig::downloadDir(); + + + // =========== Fonts ============== + QFont standardFont = ReKonfig::standardFont(); + QFont fixedFont = ReKonfig::fixedFont(); + + QWebSettings *defaultSettings = QWebSettings::globalSettings(); + defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); + defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); + defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); + + + // =========== Privacy ============== + + bool arePluginsEnabled = ReKonfig::enablePlugins(); + bool isJavascriptEnabled = ReKonfig::enableJavascript(); + + defaultSettings->setAttribute(QWebSettings::PluginsEnabled, arePluginsEnabled); + defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, isJavascriptEnabled); + +// int canAcceptCookies = ReKonfig::acceptCookies(); +// int canKeepCookiesUntil = ReKonfig::keepCookiesUntil(); +// +// CookieJar::KeepPolicy keepCookies; +// switch(canAcceptCookies) +// { +// default: +// case 0: +// keepCookies = CookieJar::KeepUntilExpire; +// break; +// case 1: +// keepCookies = CookieJar::KeepUntilExit; +// break; +// case 2: +// keepCookies = CookieJar::KeepUntilTimeLimit; +// break; +// } +// CookieJar *jar = BrowserApplication::cookieJar(); +// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); +// +// CookieJar::KeepPolicy keepPolicy; +// switch(canKeepCookiesUntil) +// { +// default: +// case 0: +// keepPolicy = CookieJar::KeepUntilExpire; +// break; +// case 1: +// keepPolicy = CookieJar::KeepUntilExit; +// break; +// case 2: +// keepPolicy = CookieJar::KeepUntilTimeLimit; +// break; +// } +// +// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); +// // --- +// BrowserApplication::instance()->loadSettings(); +// BrowserApplication::networkAccessManager()->loadSettings(); +// BrowserApplication::cookieJar()->loadSettings(); +// BrowserApplication::historyManager()->loadSettings(); + +} + + KUrl MainWindow::guessUrlFromString(const QString &string) { QString urlStr = string.trimmed(); @@ -576,10 +668,7 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("Global Settings"); - QString home = group.readEntry( QString("home"), QString("http://www.kde.org/") ); - loadUrl( KUrl(home) ); + loadUrl( KUrl(m_homePage) ); } diff --git a/src/mainwindow.h b/src/mainwindow.h index fd7f13d6..e666e405 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -65,6 +65,8 @@ private: void setupTabBar(); public slots: + void updateConfiguration(); + void slotHome(); void loadUrl(const KUrl &url); @@ -126,6 +128,8 @@ private: QString m_lastSearch; MainView *m_tabWidget; + + QString m_homePage; }; #endif // MAINWINDOW_H diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg new file mode 100644 index 00000000..4e91847b --- /dev/null +++ b/src/rekonq.kcfg @@ -0,0 +1,73 @@ + + + + + +QtWebKit +KUrl + + + + + http://www.kde.org/ + + + $HOME + + + 1 + + + + + + + QFont( QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont) ) + + + QFont( QWebSettings::globalSettings()->fontFamily(QWebSettings::FixedFont) ) + + + + + + + true + + + true + + + 0 + + + 0 + + + + + + + false + + + Socks5 + + + + + + 1080 + + + + + + + + + + diff --git a/src/rekonq.kcfgc b/src/rekonq.kcfgc new file mode 100644 index 00000000..50a9817d --- /dev/null +++ b/src/rekonq.kcfgc @@ -0,0 +1,5 @@ +File=rekonq.kcfg +ClassName=ReKonfig +Singleton=true +Mutators=true +UseEnumTypes=true diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 323e775b..3a9ab682 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -57,13 +57,17 @@ -&Settings - - + + &Settings + + - + diff --git a/src/settings.cpp b/src/settings.cpp index 23b04c83..c06cbc85 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -19,10 +19,14 @@  * ============================================================ */ -// Local Includes +// Self Includes #include "settings.h" #include "settings.moc" +// Auto Includes +#include "rekonq.h" + +// Local Includes #include "browserapplication.h" #include "mainwindow.h" #include "cookiejar.h" @@ -32,7 +36,7 @@ //Ui Includes #include "ui_settings_general.h" -#include "ui_settings_appearance.h" +#include "ui_settings_fonts.h" #include "ui_settings_privacy.h" #include "ui_settings_proxy.h" @@ -52,7 +56,7 @@ class Private { private: Ui::general generalUi; - Ui::appearance appearanceUi; + Ui::fonts fontsUi; Ui::privacy privacyUi; Ui::proxy proxyUi; @@ -72,10 +76,10 @@ Private::Private(SettingsDialog *parent) widget->layout()->setMargin(0); pageItem = parent->addPage( widget , i18n("General") ); pageItem->setIcon( KIcon("rekonq") ); - generalUi.kurlrequester->setMode( KFile::Directory ); + generalUi.kcfg_downloadDir->setMode( KFile::Directory ); widget = new QWidget; - appearanceUi.setupUi( widget ); + fontsUi.setupUi( widget ); widget->layout()->setMargin(0); pageItem = parent->addPage( widget , i18n("Fonts") ); pageItem->setIcon( KIcon("preferences-desktop-font") ); @@ -96,7 +100,7 @@ Private::Private(SettingsDialog *parent) // ----------------------------------------------------------------------------------------------------- SettingsDialog::SettingsDialog(QWidget *parent) - : KConfigDialog(parent, "Settings", new KConfigSkeleton("rekonqrc") ) + : KConfigDialog(parent, "settings", ReKonfig::self() ) , d(new Private(this) ) { setFaceType(KPageDialog::List); @@ -106,223 +110,221 @@ SettingsDialog::SettingsDialog(QWidget *parent) setWindowTitle( i18n("rekonfig..") ); setModal(true); - connect(this, SIGNAL( okClicked() ), this, SLOT( slotOk() ) ); - connect(this, SIGNAL( closeClicked() ), this, SLOT( close() ) ); - connect(this, SIGNAL( applyClicked() ), this, SLOT( slotApply() ) ); + connect(this, SIGNAL(settingsChanged(const QString&)), parent, SLOT(updateConfiguration())); +// connect(this, SIGNAL(settingsChanged(const QString&)), this, SLOT(loadFromSettings())); + connect( d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); connect( d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); connect( d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT( showCookies() ) ); - connect( d->appearanceUi.standardFontButton, SIGNAL(clicked()), this, SLOT( chooseFont() ) ); - connect( d->appearanceUi.fixedFontButton, SIGNAL(clicked()), this, SLOT( chooseFixedFont() ) ); - - loadDefaults(); - loadFromSettings(); } + SettingsDialog::~SettingsDialog() { delete d; } -void SettingsDialog::loadDefaults() -{ - QWebSettings *defaultSettings = QWebSettings::globalSettings(); - QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); - int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); - m_standardFont = QFont(standardFontFamily, standardFontSize); - d->appearanceUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() )); - - QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); - int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); - m_fixedFont = QFont(fixedFontFamily, fixedFontSize); - d->appearanceUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); - - d->generalUi.kurlrequester->setUrl( KUrl( "~" ) ); // QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) ); - - d->privacyUi.enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); - d->privacyUi.enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); -} - - -void SettingsDialog::loadFromSettings() -{ - KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("Global Settings"); - - QString defaultHome = QString("http://www.kde.org"); - d->generalUi.homeLineEdit->setText( group1.readEntry(QString("home"), defaultHome) ); - - int historyExpire = group1.readEntry( QString("historyExpire"), QString().toInt() ); - int idx = 0; - switch (historyExpire) - { - case 1: idx = 0; break; - case 7: idx = 1; break; - case 14: idx = 2; break; - case 30: idx = 3; break; - case 365: idx = 4; break; - case -1: idx = 5; break; - default: idx = 5; - } - d->generalUi.expireHistory->setCurrentIndex(idx); - - QString downloadDirectory = group1.readEntry( QString("downloadDirectory") , QString() ); - d->generalUi.kurlrequester->setUrl( KUrl(downloadDirectory) ); - - d->generalUi.openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ) ); - - - // Appearance - KConfigGroup group2 = config.group("Fonts Settings"); - - m_fixedFont = group2.readEntry( QString("fixedFont"), m_fixedFont ); - m_standardFont = group2.readEntry( QString("standardFont"), m_standardFont ); - - d->appearanceUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); - d->appearanceUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); - - // Privacy - KConfigGroup group3 = config.group("Privacy Settings"); - - d->privacyUi.enableJavascript->setChecked( group3.readEntry( QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ) ); - d->privacyUi.enablePlugins->setChecked( group3.readEntry( QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ) ); - - CookieJar *jar = BrowserApplication::cookieJar(); - QString value = group3.readEntry( QString("acceptCookies"), QString("AcceptOnlyFromSitesNavigatedTo") ) ; - QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); - CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? - CookieJar::AcceptOnlyFromSitesNavigatedTo : - static_cast(acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) ); - switch(acceptCookies) - { - case CookieJar::AcceptAlways: - d->privacyUi.acceptCombo->setCurrentIndex(0); - break; - case CookieJar::AcceptNever: - d->privacyUi.acceptCombo->setCurrentIndex(1); - break; - case CookieJar::AcceptOnlyFromSitesNavigatedTo: - d->privacyUi.acceptCombo->setCurrentIndex(2); - break; - } - - value = group3.readEntry( QString("keepCookiesUntil"), QString("Expire") ); - QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); - CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? - CookieJar::KeepUntilExpire : - static_cast(keepPolicyEnum.keyToValue( value.toLocal8Bit() ) ); - switch(keepCookies) - { - case CookieJar::KeepUntilExpire: - d->privacyUi.keepUntilCombo->setCurrentIndex(0); - break; - case CookieJar::KeepUntilExit: - d->privacyUi.keepUntilCombo->setCurrentIndex(1); - break; - case CookieJar::KeepUntilTimeLimit: - d->privacyUi.keepUntilCombo->setCurrentIndex(2); - break; - } - - // Proxy - KConfigGroup group4 = config.group("Proxy Settings"); - - d->proxyUi.proxySupport->setChecked( group4.readEntry( QString("enabled"), false ) ); - d->proxyUi.proxyType->setCurrentIndex( group4.readEntry( QString("type"), 0) ); - d->proxyUi.proxyHostName->setText( group4.readEntry( QString("hostName"), QString() ) ); - d->proxyUi.proxyPort->setValue( group4.readEntry( QString("port"), QString().toInt() ) ); - d->proxyUi.proxyUserName->setText( group4.readEntry( QString("userName") , QString() ) ); - d->proxyUi.proxyPassword->setText( group4.readEntry( QString("password") , QString() ) ); - -} - - -void SettingsDialog::saveToSettings() +//void SettingsDialog::loadDefaults() +//{ +// QWebSettings *defaultSettings = QWebSettings::globalSettings(); +// QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); +// int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); +// m_standardFont = QFont(standardFontFamily, standardFontSize); +// d->fontsUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() )); +// +// QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); +// int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); +// m_fixedFont = QFont(fixedFontFamily, fixedFontSize); +// d->fontsUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); +// +// d->generalUi.kurlrequester->setUrl( KUrl( "~" ) ); // QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) ); +// +// d->privacyUi.enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); +// d->privacyUi.enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); +// } +// +// + +/*void SettingsDialog::loadFromSettings() { - KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("Global Settings"); - - group1.writeEntry(QString("home"), d->generalUi.homeLineEdit->text() ); - group1.writeEntry(QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ); - group1.writeEntry(QString("downloadDirectory"), d->generalUi.kurlrequester->url().path() ); - - int historyExpire = d->generalUi.expireHistory->currentIndex(); - int idx = -1; - switch (historyExpire) - { - case 0: idx = 1; break; - case 1: idx = 7; break; - case 2: idx = 14; break; - case 3: idx = 30; break; - case 4: idx = 365; break; - case 5: idx = -1; break; - } - group1.writeEntry(QString("historyExpire"), idx ); - - KConfigGroup group2 = config.group("Fonts Settings"); - group2.writeEntry(QString("fixedFont"), m_fixedFont); - group2.writeEntry(QString("standardFont"), m_standardFont); - - KConfigGroup group3 = config.group("Privacy Settings"); - group3.writeEntry(QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ); - group3.writeEntry(QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ); - - CookieJar::KeepPolicy keepCookies; - switch( d->privacyUi.acceptCombo->currentIndex() ) - { - default: - case 0: - keepCookies = CookieJar::KeepUntilExpire; - break; - case 1: - keepCookies = CookieJar::KeepUntilExit; - break; - case 2: - keepCookies = CookieJar::KeepUntilTimeLimit; - break; - } - CookieJar *jar = BrowserApplication::cookieJar(); - QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); - group3.writeEntry(QString("acceptCookies"), QString(acceptPolicyEnum.valueToKey(keepCookies) ) ); - - CookieJar::KeepPolicy keepPolicy; - switch( d->privacyUi.keepUntilCombo->currentIndex() ) - { - default: - case 0: - keepPolicy = CookieJar::KeepUntilExpire; - break; - case 1: - keepPolicy = CookieJar::KeepUntilExit; - break; - case 2: - keepPolicy = CookieJar::KeepUntilTimeLimit; - break; - } - - QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); - group3.writeEntry(QString("keepCookiesUntil"), QString(keepPolicyEnum.valueToKey(keepPolicy) ) ); - - - KConfigGroup group4 = config.group("Proxy Settings"); - group4.writeEntry(QString("enabled"), d->proxyUi.proxySupport->isChecked() ); - group4.writeEntry(QString("type"), d->proxyUi.proxyType->currentIndex() ); - group4.writeEntry(QString("hostName"), d->proxyUi.proxyHostName->text() ); - group4.writeEntry(QString("port"), d->proxyUi.proxyPort->text() ); - group4.writeEntry(QString("userName"), d->proxyUi.proxyUserName->text() ); - group4.writeEntry(QString("password"), d->proxyUi.proxyPassword->text() ); - - config.sync(); - - // --- - BrowserApplication::instance()->loadSettings(); - BrowserApplication::networkAccessManager()->loadSettings(); - BrowserApplication::cookieJar()->loadSettings(); - BrowserApplication::historyManager()->loadSettings(); -} + KConfig config("rekonqrc"); +// KConfigGroup group1 = config.group("Global Settings"); +// +// QString defaultHome = QString("http://www.kde.org"); +// d->generalUi.homeLineEdit->setText( group1.readEntry(QString("home"), defaultHome) ); +// +// int historyExpire = group1.readEntry( QString("historyExpire"), QString().toInt() ); +// int idx = 0; +// switch (historyExpire) +// { +// case 1: idx = 0; break; +// case 7: idx = 1; break; +// case 14: idx = 2; break; +// case 30: idx = 3; break; +// case 365: idx = 4; break; +// case -1: idx = 5; break; +// default: idx = 5; +// } +// d->generalUi.expireHistory->setCurrentIndex(idx); +// +// QString downloadDirectory = group1.readEntry( QString("downloadDirectory") , QString() ); +// d->generalUi.kurlrequester->setUrl( KUrl(downloadDirectory) ); +// +// d->generalUi.openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ) ); +// +// + + // ===== Fonts + KConfigGroup fontsGroup = config.group("Fonts Settings"); + + m_standardFont = fontsGroup.readEntry( QString("standardFont"), m_standardFont ); + d->fontsUi.kcfg_standardFont->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); + + m_fixedFont = fontsGroup.readEntry( QString("fixedFont"), m_fixedFont ); + d->fontsUi.kcfg_fixedFont->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); +// +// // Privacy +// KConfigGroup group3 = config.group("Privacy Settings"); +// +// d->privacyUi.enableJavascript->setChecked( group3.readEntry( QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ) ); +// d->privacyUi.enablePlugins->setChecked( group3.readEntry( QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ) ); +// +// CookieJar *jar = BrowserApplication::cookieJar(); +// QString value = group3.readEntry( QString("acceptCookies"), QString("AcceptOnlyFromSitesNavigatedTo") ) ; +// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); +// CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? +// CookieJar::AcceptOnlyFromSitesNavigatedTo : +// static_cast(acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) ); +// switch(acceptCookies) +// { +// case CookieJar::AcceptAlways: +// d->privacyUi.acceptCombo->setCurrentIndex(0); +// break; +// case CookieJar::AcceptNever: +// d->privacyUi.acceptCombo->setCurrentIndex(1); +// break; +// case CookieJar::AcceptOnlyFromSitesNavigatedTo: +// d->privacyUi.acceptCombo->setCurrentIndex(2); +// break; +// } +// +// value = group3.readEntry( QString("keepCookiesUntil"), QString("Expire") ); +// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); +// CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? +// CookieJar::KeepUntilExpire : +// static_cast(keepPolicyEnum.keyToValue( value.toLocal8Bit() ) ); +// switch(keepCookies) +// { +// case CookieJar::KeepUntilExpire: +// d->privacyUi.keepUntilCombo->setCurrentIndex(0); +// break; +// case CookieJar::KeepUntilExit: +// d->privacyUi.keepUntilCombo->setCurrentIndex(1); +// break; +// case CookieJar::KeepUntilTimeLimit: +// d->privacyUi.keepUntilCombo->setCurrentIndex(2); +// break; +// } +// +// // Proxy +// KConfigGroup group4 = config.group("Proxy Settings"); +// +// d->proxyUi.proxySupport->setChecked( group4.readEntry( QString("enabled"), false ) ); +// d->proxyUi.proxyType->setCurrentIndex( group4.readEntry( QString("type"), 0) ); +// d->proxyUi.proxyHostName->setText( group4.readEntry( QString("hostName"), QString() ) ); +// d->proxyUi.proxyPort->setValue( group4.readEntry( QString("port"), QString().toInt() ) ); +// d->proxyUi.proxyUserName->setText( group4.readEntry( QString("userName") , QString() ) ); +// d->proxyUi.proxyPassword->setText( group4.readEntry( QString("password") , QString() ) ); +// +}*/ +// +// +// void SettingsDialog::saveToSettings() +// { +// KConfig config("rekonqrc"); +// KConfigGroup group1 = config.group("Global Settings"); +// +// group1.writeEntry(QString("home"), d->generalUi.homeLineEdit->text() ); +// group1.writeEntry(QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ); +// group1.writeEntry(QString("downloadDirectory"), d->generalUi.kurlrequester->url().path() ); +// +// int historyExpire = d->generalUi.expireHistory->currentIndex(); +// int idx = -1; +// switch (historyExpire) +// { +// case 0: idx = 1; break; +// case 1: idx = 7; break; +// case 2: idx = 14; break; +// case 3: idx = 30; break; +// case 4: idx = 365; break; +// case 5: idx = -1; break; +// } +// group1.writeEntry(QString("historyExpire"), idx ); +// +// KConfigGroup group2 = config.group("Fonts Settings"); +// group2.writeEntry(QString("fixedFont"), m_fixedFont); +// group2.writeEntry(QString("standardFont"), m_standardFont); +// +// KConfigGroup group3 = config.group("Privacy Settings"); +// group3.writeEntry(QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ); +// group3.writeEntry(QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ); +// +// CookieJar::KeepPolicy keepCookies; +// switch( d->privacyUi.acceptCombo->currentIndex() ) +// { +// default: +// case 0: +// keepCookies = CookieJar::KeepUntilExpire; +// break; +// case 1: +// keepCookies = CookieJar::KeepUntilExit; +// break; +// case 2: +// keepCookies = CookieJar::KeepUntilTimeLimit; +// break; +// } +// CookieJar *jar = BrowserApplication::cookieJar(); +// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); +// group3.writeEntry(QString("acceptCookies"), QString(acceptPolicyEnum.valueToKey(keepCookies) ) ); +// +// CookieJar::KeepPolicy keepPolicy; +// switch( d->privacyUi.keepUntilCombo->currentIndex() ) +// { +// default: +// case 0: +// keepPolicy = CookieJar::KeepUntilExpire; +// break; +// case 1: +// keepPolicy = CookieJar::KeepUntilExit; +// break; +// case 2: +// keepPolicy = CookieJar::KeepUntilTimeLimit; +// break; +// } +// +// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); +// group3.writeEntry(QString("keepCookiesUntil"), QString(keepPolicyEnum.valueToKey(keepPolicy) ) ); +// +// +// KConfigGroup group4 = config.group("Proxy Settings"); +// group4.writeEntry(QString("enabled"), d->proxyUi.proxySupport->isChecked() ); +// group4.writeEntry(QString("type"), d->proxyUi.proxyType->currentIndex() ); +// group4.writeEntry(QString("hostName"), d->proxyUi.proxyHostName->text() ); +// group4.writeEntry(QString("port"), d->proxyUi.proxyPort->text() ); +// group4.writeEntry(QString("userName"), d->proxyUi.proxyUserName->text() ); +// group4.writeEntry(QString("password"), d->proxyUi.proxyPassword->text() ); +// +// config.sync(); +// +// // --- +// BrowserApplication::instance()->loadSettings(); +// BrowserApplication::networkAccessManager()->loadSettings(); +// BrowserApplication::cookieJar()->loadSettings(); +// BrowserApplication::historyManager()->loadSettings(); +// } void SettingsDialog::showCookies() @@ -339,29 +341,29 @@ void SettingsDialog::showExceptions() } -void SettingsDialog::chooseFont() -{ - QFont myFont( m_standardFont ); - int result = KFontDialog::getFont( myFont ); - if ( result == KFontDialog::Accepted ) - { - m_standardFont = myFont; - d->appearanceUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); - } -} - - -void SettingsDialog::chooseFixedFont() -{ - - QFont myFont( m_fixedFont ); - int result = KFontDialog::getFont( myFont , KFontChooser::FixedFontsOnly ); - if ( result == KFontDialog::Accepted ) - { - m_fixedFont = myFont; - d->appearanceUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); - } -} +// void SettingsDialog::chooseStandardFont() +// { +// QFont myFont( m_standardFont ); +// int result = KFontDialog::getFont( myFont ); +// if ( result == KFontDialog::Accepted ) +// { +// m_standardFont = myFont; +// d->fontsUi.kcfg_standardFont->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); +// } +// } +// +// +// void SettingsDialog::chooseFixedFont() +// { +// +// QFont myFont( m_fixedFont ); +// int result = KFontDialog::getFont( myFont , KFontChooser::FixedFontsOnly ); +// if ( result == KFontDialog::Accepted ) +// { +// m_fixedFont = myFont; +// d->fontsUi.kcfg_fixedFont->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); +// } +// } void SettingsDialog::setHomeToCurrentPage() @@ -370,10 +372,10 @@ void SettingsDialog::setHomeToCurrentPage() WebView *webView = mw->currentTab(); if (webView) { - d->generalUi.homeLineEdit->setText( webView->url().prettyUrl() ); + d->generalUi.kcfg_homePage->setText( webView->url().prettyUrl() ); } } - +/* void SettingsDialog::slotOk() { @@ -384,4 +386,4 @@ void SettingsDialog::slotOk() void SettingsDialog::slotApply() { saveToSettings(); -} +}*/ diff --git a/src/settings.h b/src/settings.h index 79059ed6..f9ae6828 100644 --- a/src/settings.h +++ b/src/settings.h @@ -41,23 +41,17 @@ private: Private* const d; private slots: - void loadDefaults(); - void loadFromSettings(); - void saveToSettings(); - +// void loadFromSettings(); void setHomeToCurrentPage(); void showCookies(); void showExceptions(); - - void chooseFont(); +/* + void chooseStandardFont(); void chooseFixedFont(); - void slotOk(); - void slotApply(); - private: QFont m_standardFont; - QFont m_fixedFont; + QFont m_fixedFont;*/ }; #endif // SETTINGS_H diff --git a/src/settings_appearance.ui b/src/settings_appearance.ui deleted file mode 100644 index ec82297c..00000000 --- a/src/settings_appearance.ui +++ /dev/null @@ -1,98 +0,0 @@ - - appearance - - - - 0 - 0 - 445 - 92 - - - - Appearance - - - - - - - - Standard font: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Fixed-width font: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - Times 16 - - - Qt::AlignCenter - - - - - - - QFrame::StyledPanel - - - Courier 13 - - - Qt::AlignCenter - - - - - - - - - - - Select... - - - - - - - Select... - - - - - - - - - - diff --git a/src/settings_fonts.ui b/src/settings_fonts.ui new file mode 100644 index 00000000..beaa3afe --- /dev/null +++ b/src/settings_fonts.ui @@ -0,0 +1,64 @@ + + fonts + + + + 0 + 0 + 391 + 179 + + + + Appearance + + + + + + Standard Font + + + + + + + + + + + + Fixed Font + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + KFontRequester + QWidget +
kfontrequester.h
+
+
+ + +
diff --git a/src/settings_general.ui b/src/settings_general.ui index 4857488a..47dbad81 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -5,7 +5,7 @@ 0 0 - 575 + 500 209 @@ -24,7 +24,14 @@ - + + + + 0 + 0 + + + @@ -57,7 +64,7 @@ - + After one day @@ -101,33 +108,9 @@ - - - - - - Open links from applications: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + - - - - In a tab in the current window - - - - - In a new window - - - - - Qt::Vertical diff --git a/src/settings_privacy.ui b/src/settings_privacy.ui index dfa61998..19e7f088 100644 --- a/src/settings_privacy.ui +++ b/src/settings_privacy.ui @@ -6,7 +6,7 @@ 0 0 461 - 212 + 313 @@ -20,7 +20,7 @@ - + Enable Plugins @@ -30,7 +30,7 @@ - + Enable Javascript @@ -59,7 +59,7 @@ - + Always @@ -95,7 +95,7 @@ - + They expire @@ -123,6 +123,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/settings_proxy.ui b/src/settings_proxy.ui index c02dad27..a7dd6073 100644 --- a/src/settings_proxy.ui +++ b/src/settings_proxy.ui @@ -14,13 +14,10 @@ - + Enable proxy - - true - @@ -33,7 +30,7 @@ - + Socks5 @@ -57,7 +54,7 @@ - + @@ -70,7 +67,7 @@ - + 10000 @@ -103,7 +100,7 @@ - + @@ -116,7 +113,7 @@ - + diff --git a/src/webview.cpp b/src/webview.cpp index 62acbba6..df629fc8 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -305,8 +305,8 @@ void WebView::downloadRequested(const QNetworkRequest &request) const KUrl url = KUrl( request.url() ); KConfig config("rekonqrc"); - KConfigGroup group1 = config.group("Global Settings"); - QString path = group1.readEntry(QString("downloadDirectory")) + QString("/") + url.fileName(); + KConfigGroup group = config.group("General"); + QString path = group.readEntry(QString("downloadDir")) + QString("/") + url.fileName(); KIO::NetAccess::download( url , path , this ); } -- cgit v1.2.1 From 93755c7a74614c795036d0830cf080b7e4ff5654 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 18 Jan 2009 02:18:29 +0100 Subject: m_tabWidget --> m_view --- src/mainwindow.cpp | 84 +++++++++++++++++++++++++++--------------------------- src/mainwindow.h | 2 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6c177103..bdf2120d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -60,7 +60,7 @@ MainWindow::MainWindow() : KXmlGuiWindow() - , m_tabWidget( new MainView(this) ) + , m_view( new MainView(this) ) { // accept dnd setAcceptDrops(true); @@ -69,22 +69,22 @@ MainWindow::MainWindow() updateConfiguration(); // creating a new tab - m_tabWidget->newTab(); + m_view->newTab(); // tell the KXmlGuiWindow that this is indeed the main widget - setCentralWidget(m_tabWidget); + setCentralWidget(m_view); // connect signals and slots - connect(m_tabWidget, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); - connect(m_tabWidget, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); - connect(m_tabWidget, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_tabWidget, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_tabWidget, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); - connect(m_tabWidget, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); - connect(m_tabWidget, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); - connect(m_tabWidget, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); - connect(m_tabWidget, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); - connect(m_tabWidget, SIGNAL( lastTabClosed() ), m_tabWidget, SLOT(newTab() ) ); + connect(m_view, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); + connect(m_view, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); + connect(m_view, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); + connect(m_view, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); + connect(m_view, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); + connect(m_view, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); + connect(m_view, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); + connect(m_view, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); + connect(m_view, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); + connect(m_view, SIGNAL( lastTabClosed() ), m_view, SLOT(newTab() ) ); slotUpdateWindowTitle(); @@ -109,7 +109,7 @@ MainWindow::MainWindow() // setting up custom widgets.. KToolBar *navigationBar = toolBar( "mainToolBar" ); - navigationBar->addWidget( m_tabWidget->lineEditStack() ); + navigationBar->addWidget( m_view->lineEditStack() ); m_searchBar = new SearchBar( this ); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); @@ -146,20 +146,20 @@ void MainWindow::setupActions() KStandardAction::preferences( this, SLOT( slotPreferences() ), actionCollection() ); // WEB Actions (NO KStandardActions..) - KStandardAction::redisplay( m_tabWidget, SLOT( slotWebReload() ), actionCollection() ); - KStandardAction::back( m_tabWidget, SLOT( slotWebBack() ), actionCollection() ); - KStandardAction::forward( m_tabWidget, SLOT( slotWebForward() ), actionCollection() ); - KStandardAction::undo( m_tabWidget, SLOT( slotWebUndo() ), actionCollection() ); - KStandardAction::redo( m_tabWidget, SLOT( slotWebRedo() ), actionCollection() ); - KStandardAction::cut( m_tabWidget, SLOT( slotWebCut() ), actionCollection() ); - KStandardAction::copy( m_tabWidget, SLOT( slotWebCopy() ), actionCollection() ); - KStandardAction::paste( m_tabWidget, SLOT( slotWebPaste() ), actionCollection() ); - KStandardAction::selectAll( m_tabWidget, SLOT( slotWebSelectAll() ), actionCollection() ); + KStandardAction::redisplay( m_view, SLOT( slotWebReload() ), actionCollection() ); + KStandardAction::back( m_view, SLOT( slotWebBack() ), actionCollection() ); + KStandardAction::forward( m_view, SLOT( slotWebForward() ), actionCollection() ); + KStandardAction::undo( m_view, SLOT( slotWebUndo() ), actionCollection() ); + KStandardAction::redo( m_view, SLOT( slotWebRedo() ), actionCollection() ); + KStandardAction::cut( m_view, SLOT( slotWebCut() ), actionCollection() ); + KStandardAction::copy( m_view, SLOT( slotWebCopy() ), actionCollection() ); + KStandardAction::paste( m_view, SLOT( slotWebPaste() ), actionCollection() ); + KStandardAction::selectAll( m_view, SLOT( slotWebSelectAll() ), actionCollection() ); a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); actionCollection()->addAction( QLatin1String("stop"), a ); - connect( a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT( slotWebStop() ) ); + connect( a, SIGNAL( triggered(bool) ), m_view, SLOT( slotWebStop() ) ); // stop reload Action m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); @@ -226,22 +226,22 @@ void MainWindow::setupActions() a = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); actionCollection()->addAction( QLatin1String("new tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(newTab())); + connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(newTab())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); a->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); actionCollection()->addAction( QLatin1String("close tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(closeTab())); + connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(closeTab())); a = new KAction(i18n("Show Next Tab"), this); a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); actionCollection()->addAction( QLatin1String("show next tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(nextTab())); + connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); actionCollection()->addAction( QLatin1String("show prev tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_tabWidget, SLOT(previousTab())); + connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(previousTab())); } @@ -252,14 +252,14 @@ void MainWindow::setupTabBar() addTabButton->setDefaultAction( actionCollection()->action("new tab") ); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_tabWidget->setCornerWidget(addTabButton, Qt::TopLeftCorner); + m_view->setCornerWidget(addTabButton, Qt::TopLeftCorner); // right corner button QToolButton *closeTabButton = new QToolButton(this); closeTabButton->setDefaultAction( actionCollection()->action("close tab") ); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); - m_tabWidget->setCornerWidget(closeTabButton, Qt::TopRightCorner); + m_view->setCornerWidget(closeTabButton, Qt::TopRightCorner); } @@ -267,7 +267,7 @@ void MainWindow::setupCustomMenu() { // -------------------------------- HISTORY MENU ----------------------------------------------------------------------- HistoryMenu *historyMenu = new HistoryMenu(this); - connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_tabWidget, SLOT(loadUrlInCurrentTab(const KUrl&))); + connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_view, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle( i18n("Hi&story") ); menuBar()->insertMenu( actionCollection()->action("bookmarks"), historyMenu); @@ -275,7 +275,7 @@ void MainWindow::setupCustomMenu() historyActions.append( actionCollection()->action("history back") ); historyActions.append( actionCollection()->action("history forward") ); - historyActions.append( m_tabWidget->recentlyClosedTabsAction() ); + historyActions.append( m_view->recentlyClosedTabsAction() ); historyMenu->setInitialActions(historyActions); } @@ -428,8 +428,8 @@ void MainWindow::loadUrl(const KUrl &url) if (!currentTab() || url.isEmpty()) return; - m_tabWidget->currentLineEdit()->setText( url.prettyUrl() ); - m_tabWidget->loadUrlInCurrentTab(url); + m_view->currentLineEdit()->setText( url.prettyUrl() ); + m_view->loadUrlInCurrentTab(url); } @@ -441,8 +441,8 @@ void MainWindow::slotDownloadManager() void MainWindow::slotOpenLocation() { - m_tabWidget->currentLineEdit()->selectAll(); - m_tabWidget->currentLineEdit()->setFocus(); + m_view->currentLineEdit()->selectAll(); + m_view->currentLineEdit()->setFocus(); } @@ -569,10 +569,10 @@ void MainWindow::slotPrivateBrowsing() // void MainWindow::closeEvent(QCloseEvent *event) // { -// if (m_tabWidget->count() > 1) +// if (m_view->count() > 1) // { // int ret = KMessageBox::warningYesNo(this, -// i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_tabWidget->count() ), +// i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_view->count() ), // i18n("Closing") // ); // if (ret == KMessageBox::No) @@ -683,7 +683,7 @@ void MainWindow::slotToggleInspector(bool enable) i18n("Web Inspector") ); if (result == KMessageBox::Yes) { - m_tabWidget->reloadAllTabs(); + m_view->reloadAllTabs(); } } } @@ -693,7 +693,7 @@ void MainWindow::slotSwapFocus() { if ( currentTab()->hasFocus() ) { - m_tabWidget->currentLineEdit()->setFocus(); + m_view->currentLineEdit()->setFocus(); } else { @@ -704,14 +704,14 @@ void MainWindow::slotSwapFocus() MainView *MainWindow::tabWidget() const { - return m_tabWidget; + return m_view; } WebView *MainWindow::currentTab() const { - return m_tabWidget->currentWebView(); + return m_view->currentWebView(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index e666e405..816597ee 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -127,7 +127,7 @@ private: QString m_lastSearch; - MainView *m_tabWidget; + MainView *m_view; QString m_homePage; }; -- cgit v1.2.1 From 76d30285358bedd8b2fc6caf48d2a871f7546685 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 19 Jan 2009 02:26:13 +0100 Subject: Ported tons of code to KConfigXT. To merge kcfg branch we need just to port cookie settings.. --- src/cookiejar.cpp | 57 +++++---- src/cookiejar.h | 15 +-- src/history.cpp | 29 +++-- src/history.h | 2 +- src/mainwindow.cpp | 33 +++--- src/mainwindow.h | 3 +- src/networkaccessmanager.cpp | 30 ++--- src/rekonq.kcfg | 11 +- src/settings.cpp | 267 +++++-------------------------------------- src/settings.h | 11 +- src/settings_fonts.ui | 4 +- src/settings_general.ui | 2 +- src/webview.cpp | 20 ++-- 13 files changed, 138 insertions(+), 346 deletions(-) diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index 87d84def..ef829ffd 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -18,9 +18,14 @@  *  * ============================================================ */ +// Self Includes +#include "cookiejar.h" +#include "cookiejar.moc" + +// Auto Includes +#include "rekonq.h" // Local Includes -#include "cookiejar.h" #include "autosaver.h" // KDE Includes @@ -46,6 +51,7 @@ QDataStream &operator<<(QDataStream &stream, const QList &list) return stream; } + QDataStream &operator>>(QDataStream &stream, QList &list) { list.clear(); @@ -76,6 +82,7 @@ QDataStream &operator>>(QDataStream &stream, QList &list) } QT_END_NAMESPACE + CookieJar::CookieJar(QObject *parent) : QNetworkCookieJar(parent) , m_loaded(false) @@ -84,6 +91,7 @@ CookieJar::CookieJar(QObject *parent) { } + CookieJar::~CookieJar() { if (m_keepCookies == KeepUntilExit) @@ -91,6 +99,7 @@ CookieJar::~CookieJar() m_saveTimer->saveIfNeccessary(); } + void CookieJar::clear() { setAllCookies(QList()); @@ -98,6 +107,7 @@ void CookieJar::clear() emit cookiesChanged(); } + void CookieJar::load() { if (m_loaded) @@ -130,6 +140,7 @@ void CookieJar::load() loadSettings(); } + void CookieJar::loadSettings() { KConfig config("rekonqrc"); @@ -153,6 +164,7 @@ void CookieJar::loadSettings() emit cookiesChanged(); } + void CookieJar::save() { if (!m_loaded) @@ -200,6 +212,7 @@ void CookieJar::save() group.writeEntry( QString("keepCookiesUntil"), QString( keepPolicyEnum.valueToKey(m_keepCookies) ) ); } + void CookieJar::purgeOldCookies() { QList cookies = allCookies(); @@ -218,6 +231,7 @@ void CookieJar::purgeOldCookies() emit cookiesChanged(); } + QList CookieJar::cookiesForUrl(const QUrl &url) const { CookieJar *that = const_cast(this); @@ -234,6 +248,7 @@ QList CookieJar::cookiesForUrl(const QUrl &url) const return QNetworkCookieJar::cookiesForUrl(url); } + bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url) { if (!m_loaded) @@ -297,7 +312,6 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const } - CookieJar::AcceptPolicy CookieJar::acceptPolicy() const { if (!m_loaded) @@ -306,7 +320,6 @@ CookieJar::AcceptPolicy CookieJar::acceptPolicy() const } - void CookieJar::setAcceptPolicy(AcceptPolicy policy) { if (!m_loaded) @@ -318,7 +331,6 @@ void CookieJar::setAcceptPolicy(AcceptPolicy policy) } - CookieJar::KeepPolicy CookieJar::keepPolicy() const { if (!m_loaded) @@ -327,7 +339,6 @@ CookieJar::KeepPolicy CookieJar::keepPolicy() const } - void CookieJar::setKeepPolicy(KeepPolicy policy) { if (!m_loaded) @@ -339,7 +350,6 @@ void CookieJar::setKeepPolicy(KeepPolicy policy) } - QStringList CookieJar::blockedCookies() const { if (!m_loaded) @@ -348,7 +358,6 @@ QStringList CookieJar::blockedCookies() const } - QStringList CookieJar::allowedCookies() const { if (!m_loaded) @@ -357,7 +366,6 @@ QStringList CookieJar::allowedCookies() const } - QStringList CookieJar::allowForSessionCookies() const { if (!m_loaded) @@ -366,7 +374,6 @@ QStringList CookieJar::allowForSessionCookies() const } - void CookieJar::setBlockedCookies(const QStringList &list) { if (!m_loaded) @@ -377,7 +384,6 @@ void CookieJar::setBlockedCookies(const QStringList &list) } - void CookieJar::setAllowedCookies(const QStringList &list) { if (!m_loaded) @@ -388,7 +394,6 @@ void CookieJar::setAllowedCookies(const QStringList &list) } - void CookieJar::setAllowForSessionCookies(const QStringList &list) { if (!m_loaded) @@ -399,9 +404,7 @@ void CookieJar::setAllowForSessionCookies(const QStringList &list) } - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ------------------------------------------------------------------------------------------- CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) @@ -412,6 +415,7 @@ CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) m_cookieJar->load(); } + QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::SizeHintRole) { @@ -447,6 +451,7 @@ QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int r return QAbstractTableModel::headerData(section, orientation, role); } + QVariant CookieModel::data(const QModelIndex &index, int role) const { QList lst; @@ -484,16 +489,19 @@ QVariant CookieModel::data(const QModelIndex &index, int role) const return QVariant(); } + int CookieModel::columnCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : 6; } + int CookieModel::rowCount(const QModelIndex &parent) const { return (parent.isValid() || !m_cookieJar) ? 0 : m_cookieJar->allCookies().count(); } + bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) { if (parent.isValid() || !m_cookieJar) @@ -509,6 +517,7 @@ bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) return true; } + void CookieModel::cookiesChanged() { reset(); @@ -516,8 +525,7 @@ void CookieModel::cookiesChanged() -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - +// ------------------------------------------------------------------------------------------------ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) @@ -566,9 +574,7 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) } - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - +// --------------------------------------------------------------------------------------------------- CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent) @@ -580,6 +586,7 @@ CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *pare m_sessionCookies = m_cookieJar->allowForSessionCookies(); } + QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::SizeHintRole) { @@ -603,6 +610,7 @@ QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientat return QAbstractTableModel::headerData(section, orientation, role); } + QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const { if (index.row() < 0 || index.row() >= rowCount()) @@ -648,16 +656,19 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const return QVariant(); } + int CookieExceptionsModel::columnCount(const QModelIndex &parent) const { return (parent.isValid()) ? 0 : 2; } + int CookieExceptionsModel::rowCount(const QModelIndex &parent) const { return (parent.isValid() || !m_cookieJar) ? 0 : m_allowedCookies.count() + m_blockedCookies.count() + m_sessionCookies.count(); } + bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &parent) { if (parent.isValid() || !m_cookieJar) @@ -689,9 +700,7 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa } - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - +// ---------------------------------------------------------------------------------------------------------------- CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent) @@ -746,6 +755,7 @@ CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget * } } + void CookiesExceptionsDialog::textChanged(const QString &text) { bool enabled = !text.isEmpty(); @@ -754,6 +764,7 @@ void CookiesExceptionsDialog::textChanged(const QString &text) allowForSessionButton->setEnabled(enabled); } + void CookiesExceptionsDialog::block() { if (domainLineEdit->text().isEmpty()) @@ -763,6 +774,7 @@ void CookiesExceptionsDialog::block() m_exceptionsModel->reset(); } + void CookiesExceptionsDialog::allow() { if (domainLineEdit->text().isEmpty()) @@ -772,6 +784,7 @@ void CookiesExceptionsDialog::allow() m_exceptionsModel->reset(); } + void CookiesExceptionsDialog::allowForSession() { if (domainLineEdit->text().isEmpty()) diff --git a/src/cookiejar.h b/src/cookiejar.h index 835700f1..d4868f21 100644 --- a/src/cookiejar.h +++ b/src/cookiejar.h @@ -25,7 +25,6 @@ // KDE Includes #include - // Qt Includes #include #include @@ -109,9 +108,7 @@ private: }; - - // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ------------------------------------------------------------------------------------------------------------- class CookieModel : public QAbstractTableModel @@ -134,9 +131,7 @@ private: }; - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ---------------------------------------------------------------------------------------------------------------------- #include "ui_cookies.h" @@ -175,10 +170,7 @@ private: }; - - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - +// ----------------------------------------------------------------------------------------------------------------- #include "ui_cookiesexceptions.h" @@ -203,4 +195,3 @@ private: }; #endif // COOKIEJAR_H - diff --git a/src/history.cpp b/src/history.cpp index dedabfdd..652ee962 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -22,12 +22,14 @@ #include "history.h" #include "history.moc" +// Auto Includes +#include "rekonq.h" + // Local Includes #include "autosaver.h" #include "browserapplication.h" // KDE Includes -#include #include // Qt Includes @@ -219,10 +221,19 @@ void HistoryManager::clear() void HistoryManager::loadSettings() { - // load settings - KConfig config("rekonqrc"); - KConfigGroup group = config.group("history"); - m_historyLimit = group.readEntry( QString("historyLimit"), 30 ); + int historyExpire = ReKonfig::expireHistory(); + int days; + switch (historyExpire) + { + case 0: days = 1; break; + case 1: days = 7; break; + case 2: days = 14; break; + case 3: days = 30; break; + case 4: days = 365; break; + case 5: days = -1; break; + default: days = -1; + } + m_historyLimit = days; } @@ -297,9 +308,9 @@ void HistoryManager::load() void HistoryManager::save() { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("history"); - group.writeEntry( QString("historyLimit"), m_historyLimit ); +// KConfig config("rekonqrc"); +// KConfigGroup group = config.group("history"); +// group.writeEntry( QString("historyLimit"), m_historyLimit ); bool saveAll = m_lastSavedUrl.isEmpty(); int first = m_history.count() - 1; @@ -369,7 +380,7 @@ void HistoryManager::save() } -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// -------------------------------------------------------------------------------------------------------------------------- HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) diff --git a/src/history.h b/src/history.h index f3813855..a6b68ffb 100644 --- a/src/history.h +++ b/src/history.h @@ -64,7 +64,7 @@ public: -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// --------------------------------------------------------------------------------------------------------------- class AutoSaver; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bdf2120d..629899e4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -66,7 +66,8 @@ MainWindow::MainWindow() setAcceptDrops(true); // updating rekonq configuration - updateConfiguration(); + slotUpdateConf(); +// QTimer::singleShot(0, this, SLOT( postLaunch() ) ); // creating a new tab m_view->newTab(); @@ -118,7 +119,6 @@ MainWindow::MainWindow() // Find Bar m_findBar = new FindBar( this ); connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); - } @@ -282,28 +282,11 @@ void MainWindow::setupCustomMenu() // TODO FIXME -void MainWindow::updateConfiguration() +void MainWindow::slotUpdateConf() { // ============== General ================== m_homePage = ReKonfig::homePage(); -// int historyExpire = ReKonfig::expireHistory(); -// int days; -// switch (historyExpire) -// { -// case 0: days = 1; break; -// case 1: days = 7; break; -// case 2: days = 14; break; -// case 3: days = 30; break; -// case 4: days = 365; break; -// case 5: days = -1; break; -// default: days = -1; -// } -// m_historyExpire = days; -// -// m_downloadDir = ReKonfig::downloadDir(); - - // =========== Fonts ============== QFont standardFont = ReKonfig::standardFont(); QFont fixedFont = ReKonfig::fixedFont(); @@ -454,7 +437,17 @@ void MainWindow::slotFileSaveAs() void MainWindow::slotPreferences() { + // an instance the dialog could be already created and could be cached, + // in which case you want to display the cached dialog + if ( SettingsDialog::showDialog( "settings" ) ) + return; + + // we didn't find an instance of this dialog, so lets create it SettingsDialog *s = new SettingsDialog(this); + + // keep us informed when the user changes settings + connect( s, SIGNAL(settingsChanged(const QString&)), this, SLOT(slotUpdateConf()) ); + s->show(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 816597ee..86a3e30d 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -65,12 +65,11 @@ private: void setupTabBar(); public slots: - void updateConfiguration(); - void slotHome(); void loadUrl(const KUrl &url); private slots: + void slotUpdateConf(); void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); void slotUpdateWindowTitle(const QString &title = QString()); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 7390cd22..1d601440 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -18,17 +18,22 @@  *  * ============================================================ */ +// Self Includes +#include "networkaccessmanager.h" +#include "networkaccessmanager.moc" // Local Includes -#include "networkaccessmanager.h" #include "browserapplication.h" #include "mainwindow.h" +// Auto Includes +#include "rekonq.h" + +// Ui Includes #include "ui_passworddialog.h" #include "ui_proxy.h" // KDE Includes -#include #include // Qt Includes @@ -58,13 +63,10 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) void NetworkAccessManager::loadSettings() { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("proxy"); - QNetworkProxy proxy; - if ( group.readEntry( QString("enabled"), false) ) + if ( ReKonfig::enableProxy() ) { - if ( group.readEntry( QString("type"), 0) == 0 ) + if ( ReKonfig::proxyType() == 0 ) { proxy.setType(QNetworkProxy::Socks5Proxy); } @@ -72,10 +74,10 @@ void NetworkAccessManager::loadSettings() { proxy.setType(QNetworkProxy::HttpProxy); } - proxy.setHostName( group.readEntry( QString("hostName"), QString() ) ); - proxy.setPort( group.readEntry( QString("port"), 1080 ) ); - proxy.setUser( group.readEntry( QString("userName"), QString() ) ); - proxy.setPassword( group.readEntry( QString("password"), QString() ) ); + proxy.setHostName( ReKonfig::proxyHostName() ); + proxy.setPort( ReKonfig::proxyPort() ); + proxy.setUser( ReKonfig::proxyUserName() ); + proxy.setPassword( ReKonfig::proxyPassword() ); } setProxy(proxy); } @@ -95,7 +97,8 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent passwordDialog.iconLabel->setText(QString()); passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); - QString introMessage = i18n("Enter username and password for ") + Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + ""; + QString introMessage = i18n("Enter username and password for ") + + Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + ""; passwordDialog.introLabel->setText(introMessage); passwordDialog.introLabel->setWordWrap(true); @@ -139,8 +142,7 @@ void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QListurl().toString() + "\n\n" + QString(errors) + "\n\n"); + int ret = KMessageBox::warningYesNo( mainWindow, i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n"); if (ret == KMessageBox::Yes) reply->ignoreSslErrors(); } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 4e91847b..f55f8d67 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -11,7 +11,7 @@ - + http://www.kde.org/ @@ -53,20 +53,17 @@ false - - Socks5 + + 0 - - 1080 + 8080 - - diff --git a/src/settings.cpp b/src/settings.cpp index c06cbc85..462874f9 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -76,7 +76,6 @@ Private::Private(SettingsDialog *parent) widget->layout()->setMargin(0); pageItem = parent->addPage( widget , i18n("General") ); pageItem->setIcon( KIcon("rekonq") ); - generalUi.kcfg_downloadDir->setMode( KFile::Directory ); widget = new QWidget; fontsUi.setupUi( widget ); @@ -104,15 +103,12 @@ SettingsDialog::SettingsDialog(QWidget *parent) , d(new Private(this) ) { setFaceType(KPageDialog::List); - setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply); showButtonSeparator(true); setWindowTitle( i18n("rekonfig..") ); setModal(true); - connect(this, SIGNAL(settingsChanged(const QString&)), parent, SLOT(updateConfiguration())); -// connect(this, SIGNAL(settingsChanged(const QString&)), this, SLOT(loadFromSettings())); - + readConfig(); connect( d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); connect( d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); @@ -126,205 +122,35 @@ SettingsDialog::~SettingsDialog() delete d; } +// we need this function to UPDATE the config widget data.. +void SettingsDialog::readConfig() +{ + // ======= General + d->generalUi.downloadDirUrlRequester->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly); + d->generalUi.downloadDirUrlRequester->setUrl( ReKonfig::downloadDir() ); + connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)),this, SLOT(saveSettings())); + + // ======= Fonts + d->fontsUi.standardFontChooser->setFont(ReKonfig::standardFont(), false); + connect(d->fontsUi.standardFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); + d->fontsUi.fixedFontChooser->setFont(ReKonfig::fixedFont(), true); + connect(d->fontsUi.fixedFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); +} + -//void SettingsDialog::loadDefaults() -//{ -// QWebSettings *defaultSettings = QWebSettings::globalSettings(); -// QString standardFontFamily = defaultSettings->fontFamily(QWebSettings::StandardFont); -// int standardFontSize = defaultSettings->fontSize(QWebSettings::DefaultFontSize); -// m_standardFont = QFont(standardFontFamily, standardFontSize); -// d->fontsUi.standardLabel->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() )); -// -// QString fixedFontFamily = defaultSettings->fontFamily(QWebSettings::FixedFont); -// int fixedFontSize = defaultSettings->fontSize(QWebSettings::DefaultFixedFontSize); -// m_fixedFont = QFont(fixedFontFamily, fixedFontSize); -// d->fontsUi.fixedLabel->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() )); -// -// d->generalUi.kurlrequester->setUrl( KUrl( "~" ) ); // QDesktopServices::storageLocation(QDesktopServices::DesktopLocation) ); -// -// d->privacyUi.enableJavascript->setChecked(defaultSettings->testAttribute(QWebSettings::JavascriptEnabled)); -// d->privacyUi.enablePlugins->setChecked(defaultSettings->testAttribute(QWebSettings::PluginsEnabled)); -// } -// -// - -/*void SettingsDialog::loadFromSettings() +// we need this function to SAVE settings in rc file.. +void SettingsDialog::saveSettings() { - KConfig config("rekonqrc"); -// KConfigGroup group1 = config.group("Global Settings"); -// -// QString defaultHome = QString("http://www.kde.org"); -// d->generalUi.homeLineEdit->setText( group1.readEntry(QString("home"), defaultHome) ); -// -// int historyExpire = group1.readEntry( QString("historyExpire"), QString().toInt() ); -// int idx = 0; -// switch (historyExpire) -// { -// case 1: idx = 0; break; -// case 7: idx = 1; break; -// case 14: idx = 2; break; -// case 30: idx = 3; break; -// case 365: idx = 4; break; -// case -1: idx = 5; break; -// default: idx = 5; -// } -// d->generalUi.expireHistory->setCurrentIndex(idx); -// -// QString downloadDirectory = group1.readEntry( QString("downloadDirectory") , QString() ); -// d->generalUi.kurlrequester->setUrl( KUrl(downloadDirectory) ); -// -// d->generalUi.openLinksIn->setCurrentIndex( group1.readEntry( QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ) ); -// -// - - // ===== Fonts - KConfigGroup fontsGroup = config.group("Fonts Settings"); - - m_standardFont = fontsGroup.readEntry( QString("standardFont"), m_standardFont ); - d->fontsUi.kcfg_standardFont->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); - - m_fixedFont = fontsGroup.readEntry( QString("fixedFont"), m_fixedFont ); - d->fontsUi.kcfg_fixedFont->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); -// -// // Privacy -// KConfigGroup group3 = config.group("Privacy Settings"); -// -// d->privacyUi.enableJavascript->setChecked( group3.readEntry( QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ) ); -// d->privacyUi.enablePlugins->setChecked( group3.readEntry( QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ) ); -// -// CookieJar *jar = BrowserApplication::cookieJar(); -// QString value = group3.readEntry( QString("acceptCookies"), QString("AcceptOnlyFromSitesNavigatedTo") ) ; -// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); -// CookieJar::AcceptPolicy acceptCookies = acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? -// CookieJar::AcceptOnlyFromSitesNavigatedTo : -// static_cast(acceptPolicyEnum.keyToValue( value.toLocal8Bit() ) ); -// switch(acceptCookies) -// { -// case CookieJar::AcceptAlways: -// d->privacyUi.acceptCombo->setCurrentIndex(0); -// break; -// case CookieJar::AcceptNever: -// d->privacyUi.acceptCombo->setCurrentIndex(1); -// break; -// case CookieJar::AcceptOnlyFromSitesNavigatedTo: -// d->privacyUi.acceptCombo->setCurrentIndex(2); -// break; -// } -// -// value = group3.readEntry( QString("keepCookiesUntil"), QString("Expire") ); -// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); -// CookieJar::KeepPolicy keepCookies = keepPolicyEnum.keyToValue( value.toLocal8Bit() ) == -1 ? -// CookieJar::KeepUntilExpire : -// static_cast(keepPolicyEnum.keyToValue( value.toLocal8Bit() ) ); -// switch(keepCookies) -// { -// case CookieJar::KeepUntilExpire: -// d->privacyUi.keepUntilCombo->setCurrentIndex(0); -// break; -// case CookieJar::KeepUntilExit: -// d->privacyUi.keepUntilCombo->setCurrentIndex(1); -// break; -// case CookieJar::KeepUntilTimeLimit: -// d->privacyUi.keepUntilCombo->setCurrentIndex(2); -// break; -// } -// -// // Proxy -// KConfigGroup group4 = config.group("Proxy Settings"); -// -// d->proxyUi.proxySupport->setChecked( group4.readEntry( QString("enabled"), false ) ); -// d->proxyUi.proxyType->setCurrentIndex( group4.readEntry( QString("type"), 0) ); -// d->proxyUi.proxyHostName->setText( group4.readEntry( QString("hostName"), QString() ) ); -// d->proxyUi.proxyPort->setValue( group4.readEntry( QString("port"), QString().toInt() ) ); -// d->proxyUi.proxyUserName->setText( group4.readEntry( QString("userName") , QString() ) ); -// d->proxyUi.proxyPassword->setText( group4.readEntry( QString("password") , QString() ) ); -// -}*/ -// -// -// void SettingsDialog::saveToSettings() -// { -// KConfig config("rekonqrc"); -// KConfigGroup group1 = config.group("Global Settings"); -// -// group1.writeEntry(QString("home"), d->generalUi.homeLineEdit->text() ); -// group1.writeEntry(QString("openLinksIn"), d->generalUi.openLinksIn->currentIndex() ); -// group1.writeEntry(QString("downloadDirectory"), d->generalUi.kurlrequester->url().path() ); -// -// int historyExpire = d->generalUi.expireHistory->currentIndex(); -// int idx = -1; -// switch (historyExpire) -// { -// case 0: idx = 1; break; -// case 1: idx = 7; break; -// case 2: idx = 14; break; -// case 3: idx = 30; break; -// case 4: idx = 365; break; -// case 5: idx = -1; break; -// } -// group1.writeEntry(QString("historyExpire"), idx ); -// -// KConfigGroup group2 = config.group("Fonts Settings"); -// group2.writeEntry(QString("fixedFont"), m_fixedFont); -// group2.writeEntry(QString("standardFont"), m_standardFont); -// -// KConfigGroup group3 = config.group("Privacy Settings"); -// group3.writeEntry(QString("enableJavascript"), d->privacyUi.enableJavascript->isChecked() ); -// group3.writeEntry(QString("enablePlugins"), d->privacyUi.enablePlugins->isChecked() ); -// -// CookieJar::KeepPolicy keepCookies; -// switch( d->privacyUi.acceptCombo->currentIndex() ) -// { -// default: -// case 0: -// keepCookies = CookieJar::KeepUntilExpire; -// break; -// case 1: -// keepCookies = CookieJar::KeepUntilExit; -// break; -// case 2: -// keepCookies = CookieJar::KeepUntilTimeLimit; -// break; -// } -// CookieJar *jar = BrowserApplication::cookieJar(); -// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); -// group3.writeEntry(QString("acceptCookies"), QString(acceptPolicyEnum.valueToKey(keepCookies) ) ); -// -// CookieJar::KeepPolicy keepPolicy; -// switch( d->privacyUi.keepUntilCombo->currentIndex() ) -// { -// default: -// case 0: -// keepPolicy = CookieJar::KeepUntilExpire; -// break; -// case 1: -// keepPolicy = CookieJar::KeepUntilExit; -// break; -// case 2: -// keepPolicy = CookieJar::KeepUntilTimeLimit; -// break; -// } -// -// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); -// group3.writeEntry(QString("keepCookiesUntil"), QString(keepPolicyEnum.valueToKey(keepPolicy) ) ); -// -// -// KConfigGroup group4 = config.group("Proxy Settings"); -// group4.writeEntry(QString("enabled"), d->proxyUi.proxySupport->isChecked() ); -// group4.writeEntry(QString("type"), d->proxyUi.proxyType->currentIndex() ); -// group4.writeEntry(QString("hostName"), d->proxyUi.proxyHostName->text() ); -// group4.writeEntry(QString("port"), d->proxyUi.proxyPort->text() ); -// group4.writeEntry(QString("userName"), d->proxyUi.proxyUserName->text() ); -// group4.writeEntry(QString("password"), d->proxyUi.proxyPassword->text() ); -// -// config.sync(); -// -// // --- -// BrowserApplication::instance()->loadSettings(); -// BrowserApplication::networkAccessManager()->loadSettings(); -// BrowserApplication::cookieJar()->loadSettings(); -// BrowserApplication::historyManager()->loadSettings(); -// } + // General + ReKonfig::setDownloadDir( d->generalUi.downloadDirUrlRequester->url().prettyUrl() ); + + // Fonts + ReKonfig::setStandardFont( d->fontsUi.standardFontChooser->font() ); + ReKonfig::setFixedFont( d->fontsUi.standardFontChooser->font() ); +} + + +// ---------------------------------------------------------------------------------------------- void SettingsDialog::showCookies() @@ -341,31 +167,6 @@ void SettingsDialog::showExceptions() } -// void SettingsDialog::chooseStandardFont() -// { -// QFont myFont( m_standardFont ); -// int result = KFontDialog::getFont( myFont ); -// if ( result == KFontDialog::Accepted ) -// { -// m_standardFont = myFont; -// d->fontsUi.kcfg_standardFont->setText(QString(QLatin1String("%1 %2")).arg( m_standardFont.family() ).arg( m_standardFont.pointSize() ) ); -// } -// } -// -// -// void SettingsDialog::chooseFixedFont() -// { -// -// QFont myFont( m_fixedFont ); -// int result = KFontDialog::getFont( myFont , KFontChooser::FixedFontsOnly ); -// if ( result == KFontDialog::Accepted ) -// { -// m_fixedFont = myFont; -// d->fontsUi.kcfg_fixedFont->setText(QString(QLatin1String("%1 %2")).arg( m_fixedFont.family() ).arg( m_fixedFont.pointSize() ) ); -// } -// } - - void SettingsDialog::setHomeToCurrentPage() { MainWindow *mw = static_cast(parent()); @@ -375,15 +176,3 @@ void SettingsDialog::setHomeToCurrentPage() d->generalUi.kcfg_homePage->setText( webView->url().prettyUrl() ); } } -/* - -void SettingsDialog::slotOk() -{ - slotApply(); - close(); -} - -void SettingsDialog::slotApply() -{ - saveToSettings(); -}*/ diff --git a/src/settings.h b/src/settings.h index f9ae6828..109e3111 100644 --- a/src/settings.h +++ b/src/settings.h @@ -41,17 +41,12 @@ private: Private* const d; private slots: -// void loadFromSettings(); + void readConfig(); + void saveSettings(); + void setHomeToCurrentPage(); void showCookies(); void showExceptions(); -/* - void chooseStandardFont(); - void chooseFixedFont(); - -private: - QFont m_standardFont; - QFont m_fixedFont;*/ }; #endif // SETTINGS_H diff --git a/src/settings_fonts.ui b/src/settings_fonts.ui index beaa3afe..2d7168b0 100644 --- a/src/settings_fonts.ui +++ b/src/settings_fonts.ui @@ -20,7 +20,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/src/settings_general.ui b/src/settings_general.ui index 47dbad81..b155ed56 100644 --- a/src/settings_general.ui +++ b/src/settings_general.ui @@ -108,7 +108,7 @@ - + diff --git a/src/webview.cpp b/src/webview.cpp index df629fc8..adfeab97 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -18,19 +18,27 @@  *  * ============================================================ */ +// Local Includes +#include "webview.h" +#include "webview.moc" + +// Auto Includes +#include "rekonq.h" +// Local Includes #include "browserapplication.h" #include "mainwindow.h" #include "mainview.h" #include "cookiejar.h" #include "downloadmanager.h" #include "networkaccessmanager.h" -#include "webview.h" +// KDE Includes #include #include #include +// Qt Includes #include #include #include @@ -297,17 +305,11 @@ void WebView::setStatusBarText(const QString &string) } +// FIXME: use KIO transfer job instead!! void WebView::downloadRequested(const QNetworkRequest &request) { -// BrowserApplication::downloadManager()->download(request); - - // FIXME --- FIXME --- FIXME --- FIXME --- FIXME const KUrl url = KUrl( request.url() ); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("General"); - QString path = group.readEntry(QString("downloadDir")) + QString("/") + url.fileName(); - + QString path = ReKonfig::downloadDir() + QString("/") + url.fileName(); KIO::NetAccess::download( url , path , this ); } -- cgit v1.2.1 From aab355f785ac0cee293ff6bd0e75f1b3bd10e386 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 20 Jan 2009 01:53:20 +0100 Subject: Ported Cookie system to KCOnfigXT. Yeah! --- src/cookiejar.cpp | 82 +++++++++++++++++++++++++++++++++++++++++-------------- src/rekonq.kcfg | 2 +- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index ef829ffd..098a2d47 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -143,23 +143,39 @@ void CookieJar::load() void CookieJar::loadSettings() { - KConfig config("rekonqrc"); - KConfigGroup group = config.group("cookies"); - QByteArray value = group.readEntry( QString("acceptCookies"), QByteArray("AcceptOnlyFromSitesNavigatedTo") ); - QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("AcceptPolicy")); - m_acceptCookies = acceptPolicyEnum.keyToValue(value) == -1 ? - AcceptOnlyFromSitesNavigatedTo : - static_cast(acceptPolicyEnum.keyToValue(value)); - - value = group.readEntry( QString("keepCookiesUntil"), QByteArray("KeepUntilExpire") ); - QMetaEnum keepPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("KeepPolicy")); - m_keepCookies = keepPolicyEnum.keyToValue(value) == -1 ? - KeepUntilExpire : - static_cast(keepPolicyEnum.keyToValue(value)); + int canAcceptCookies = ReKonfig::acceptCookies(); - if (m_keepCookies == KeepUntilExit) - setAllCookies(QList()); + switch(canAcceptCookies) + { + case 0: + m_acceptCookies = AcceptAlways; + break; + case 1: + m_acceptCookies = AcceptNever; + break; + case 2: + default: + m_acceptCookies = AcceptOnlyFromSitesNavigatedTo; + break; + } + int canKeepCookiesUntil = ReKonfig::keepCookiesUntil(); + + switch(canKeepCookiesUntil) + { + default: + case 0: + m_keepCookies = KeepUntilExpire; + break; + case 1: + m_keepCookies = KeepUntilExit; + setAllCookies(QList()); + break; + case 2: + m_keepCookies = KeepUntilTimeLimit; + break; + } + m_loaded = true; emit cookiesChanged(); } @@ -203,13 +219,37 @@ void CookieJar::save() inigroup2.writeEntry( QString("allowForSession"), m_exceptions_allowForSession ); // save cookie settings - KConfig config("rekonqrc"); - KConfigGroup group = config.group("cookies"); - QMetaEnum acceptPolicyEnum = staticMetaObject.enumerator( staticMetaObject.indexOfEnumerator("AcceptPolicy") ); - group.writeEntry( QString("acceptCookies"), QString( acceptPolicyEnum.valueToKey(m_acceptCookies) ) ); + int n; + switch(m_acceptCookies) + { + case AcceptAlways: + n = 0; + break; + case AcceptNever: + n = 1; + break; + case AcceptOnlyFromSitesNavigatedTo: + default: + n = 2; + break; + } + ReKonfig::setAcceptCookies(n); - QMetaEnum keepPolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("KeepPolicy")); - group.writeEntry( QString("keepCookiesUntil"), QString( keepPolicyEnum.valueToKey(m_keepCookies) ) ); + + switch(m_keepCookies) + { + default: + case KeepUntilExpire: + n = 0; + break; + case KeepUntilExit: + n = 1; + break; + case KeepUntilTimeLimit: + n = 2; + break; + } + ReKonfig::setKeepCookiesUntil(n); } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index f55f8d67..c20134be 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -41,7 +41,7 @@ true - 0 + 2 0 -- cgit v1.2.1 From adeda3f2a1e2fc229edfa387527b102adbea646a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 20 Jan 2009 17:58:46 +0100 Subject: Removed QtDemoBrowser download manager. Working on rekonq's own.. --- src/downloaditem.ui | 134 ------------ src/downloadmanager.cpp | 544 ------------------------------------------------ src/downloadmanager.h | 142 ------------- src/downloads.ui | 83 -------- 4 files changed, 903 deletions(-) delete mode 100644 src/downloaditem.ui delete mode 100644 src/downloadmanager.cpp delete mode 100644 src/downloadmanager.h delete mode 100644 src/downloads.ui diff --git a/src/downloaditem.ui b/src/downloaditem.ui deleted file mode 100644 index 4a0a0fd9..00000000 --- a/src/downloaditem.ui +++ /dev/null @@ -1,134 +0,0 @@ - - DownloadItem - - - - 0 - 0 - 423 - 110 - - - - Form - - - - 0 - - - - - - 0 - 0 - - - - Ico - - - - - - - - - - 0 - 0 - - - - Filename - - - - - - - 0 - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Qt::Vertical - - - - 17 - 1 - - - - - - - - false - - - Try Again - - - - - - - Stop - - - - - - - Open - - - - - - - Qt::Vertical - - - - 17 - 5 - - - - - - - - - - - SqueezeLabel - QWidget -
squeezelabel.h
-
-
- - -
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp deleted file mode 100644 index df990c7b..00000000 --- a/src/downloadmanager.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -// Local includes -#include "downloadmanager.h" -#include "autosaver.h" -#include "browserapplication.h" -#include "networkaccessmanager.h" - -// generic includes -#include - -// Qt Includes -#include -#include -#include -#include -#include -#include -#include -#include - -/*! - DownloadItem is a widget that is displayed in the download manager list. - It moves the data from the QNetworkReply into the QFile as well - as update the information/progressbar and report errors. - */ -DownloadItem::DownloadItem(QNetworkReply *reply, bool requestFileName, QWidget *parent) - : QWidget(parent) - , m_reply(reply) - , m_requestFileName(requestFileName) - , m_bytesReceived(0) -{ - setupUi(this); - QPalette p = downloadInfoLabel->palette(); - p.setColor(QPalette::Text, Qt::darkGray); - downloadInfoLabel->setPalette(p); - progressBar->setMaximum(0); - tryAgainButton->hide(); - connect(stopButton, SIGNAL(clicked()), this, SLOT(stop())); - connect(openButton, SIGNAL(clicked()), this, SLOT(open())); - connect(tryAgainButton, SIGNAL(clicked()), this, SLOT(tryAgain())); - - init(); -} - -void DownloadItem::init() -{ - if (!m_reply) - return; - - // attach to the m_reply - m_url = m_reply->url(); - m_reply->setParent(this); - connect(m_reply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead())); - connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(error(QNetworkReply::NetworkError))); - connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(downloadProgress(qint64, qint64))); - connect(m_reply, SIGNAL(metaDataChanged()), this, SLOT(metaDataChanged())); - connect(m_reply, SIGNAL(finished()), this, SLOT(finished())); - - // reset info - downloadInfoLabel->clear(); - progressBar->setValue(0); - getFileName(); - - // start timer for the download estimation - m_downloadTime.start(); - - if (m_reply->error() != QNetworkReply::NoError) { - error(m_reply->error()); - finished(); - } -} - -void DownloadItem::getFileName() -{ - QSettings settings; - settings.beginGroup(QLatin1String("downloadmanager")); - QString defaultLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); - QString downloadDirectory = settings.value(QLatin1String("downloadDirectory"), defaultLocation).toString(); - if (!downloadDirectory.isEmpty()) - downloadDirectory += QLatin1Char('/'); - - QString defaultFileName = saveFileName(downloadDirectory); - QString fileName = defaultFileName; - if (m_requestFileName) { - fileName = QFileDialog::getSaveFileName(this, i18n("Save File"), defaultFileName); - if (fileName.isEmpty()) { - m_reply->close(); - fileNameLabel->setText( i18n("Download canceled: ") + QFileInfo(defaultFileName).fileName()); - return; - } - } - m_output.setFileName(fileName); - fileNameLabel->setText(QFileInfo(m_output.fileName()).fileName()); - if (m_requestFileName) - downloadReadyRead(); -} - -QString DownloadItem::saveFileName(const QString &directory) const -{ - // Move this function into QNetworkReply to also get file name sent from the server - QString path = m_url.path(); - QFileInfo info(path); - QString baseName = info.completeBaseName(); - QString endName = info.suffix(); - - if (baseName.isEmpty()) { - baseName = QLatin1String("unnamed_download"); - qDebug() << "DownloadManager:: downloading unknown file:" << m_url; - } - QString name = directory + baseName + QLatin1Char('.') + endName; - if (QFile::exists(name)) { - // already exists, don't overwrite - int i = 1; - do { - name = directory + baseName + QLatin1Char('-') + QString::number(i++) + QLatin1Char('.') + endName; - } while (QFile::exists(name)); - } - return name; -} - - -void DownloadItem::stop() -{ - setUpdatesEnabled(false); - stopButton->setEnabled(false); - stopButton->hide(); - tryAgainButton->setEnabled(true); - tryAgainButton->show(); - setUpdatesEnabled(true); - m_reply->abort(); -} - -void DownloadItem::open() -{ - QFileInfo info(m_output); - QUrl url = QUrl::fromLocalFile(info.absolutePath()); - QDesktopServices::openUrl(url); -} - -void DownloadItem::tryAgain() -{ - if (!tryAgainButton->isEnabled()) - return; - - tryAgainButton->setEnabled(false); - tryAgainButton->setVisible(false); - stopButton->setEnabled(true); - stopButton->setVisible(true); - progressBar->setVisible(true); - - QNetworkReply *r = BrowserApplication::networkAccessManager()->get(QNetworkRequest(m_url)); - if (m_reply) - m_reply->deleteLater(); - if (m_output.exists()) - m_output.remove(); - m_reply = r; - init(); - emit statusChanged(); -} - -void DownloadItem::downloadReadyRead() -{ - if (m_requestFileName && m_output.fileName().isEmpty()) - return; - if (!m_output.isOpen()) { - // in case someone else has already put a file there - if (!m_requestFileName) - getFileName(); - if (!m_output.open(QIODevice::WriteOnly)) { - downloadInfoLabel->setText( i18n("Error opening save file: ") + m_output.errorString() ); - stopButton->click(); - emit statusChanged(); - return; - } - emit statusChanged(); - } - if (-1 == m_output.write(m_reply->readAll())) { - downloadInfoLabel->setText( i18n("Error saving: ") + m_output.errorString() ); - stopButton->click(); - } -} - -void DownloadItem::error(QNetworkReply::NetworkError) -{ - qDebug() << "DownloadItem::error" << m_reply->errorString() << m_url; - downloadInfoLabel->setText( i18n("Network Error: ") + m_reply->errorString() ); - tryAgainButton->setEnabled(true); - tryAgainButton->setVisible(true); -} - -void DownloadItem::metaDataChanged() -{ - qDebug() << "DownloadItem::metaDataChanged: not handled."; -} - -void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) -{ - m_bytesReceived = bytesReceived; - if (bytesTotal == -1) { - progressBar->setValue(0); - progressBar->setMaximum(0); - } else { - progressBar->setValue(bytesReceived); - progressBar->setMaximum(bytesTotal); - } - updateInfoLabel(); -} - -void DownloadItem::updateInfoLabel() -{ - if (m_reply->error() == QNetworkReply::NoError) - return; - - qint64 bytesTotal = progressBar->maximum(); - bool running = !downloadedSuccessfully(); - - // update info label - double speed = m_bytesReceived * 1000.0 / m_downloadTime.elapsed(); - double timeRemaining = ((double)(bytesTotal - m_bytesReceived)) / speed; - QString timeRemainingString = i18n("seconds"); - if (timeRemaining > 60) { - timeRemaining = timeRemaining / 60; - timeRemainingString = i18n("minutes"); - } - timeRemaining = floor(timeRemaining); - - // When downloading the eta should never be 0 - if (timeRemaining == 0) - timeRemaining = 1; - - QString info; - if (running) { - QString remaining; - if (bytesTotal != 0) - remaining = i18n("- %1 %2 remaining", timeRemaining, timeRemainingString ); - info = dataString(m_bytesReceived) + i18n("of") + bytesTotal == 0 ? "?" : dataString(bytesTotal) + "(" + dataString((int)speed) + "/sec)" + QString(remaining); - } else { - if (m_bytesReceived == bytesTotal) - info = dataString(m_output.size()); - else - info = dataString(m_bytesReceived) + i18n("of") + dataString(bytesTotal) + i18n(" - Stopped"); - } - downloadInfoLabel->setText(info); -} - -QString DownloadItem::dataString(int size) const -{ - QString unit; - if (size < 1024) { - unit = i18n("bytes"); - } else if (size < 1024*1024) { - size /= 1024; - unit = i18n("kB"); - } else { - size /= 1024*1024; - unit = i18n("MB"); - } - return QString(QLatin1String("%1 %2")).arg(size).arg(unit); -} - -bool DownloadItem::downloading() const -{ - return (progressBar->isVisible()); -} - -bool DownloadItem::downloadedSuccessfully() const -{ - return (stopButton->isHidden() && tryAgainButton->isHidden()); -} - -void DownloadItem::finished() -{ - progressBar->hide(); - stopButton->setEnabled(false); - stopButton->hide(); - m_output.close(); - updateInfoLabel(); - emit statusChanged(); -} - -/*! - DownloadManager is a Dialog that contains a list of DownloadItems - - It is a basic download manager. It only downloads the file, doesn't do BitTorrent, - extract zipped files or anything fancy. - */ -DownloadManager::DownloadManager(QWidget *parent) - : QDialog(parent) - , m_autoSaver(new AutoSaver(this)) - , m_manager(BrowserApplication::networkAccessManager()) - , m_iconProvider(0) - , m_removePolicy(Never) -{ - setupUi(this); - downloadsView->setShowGrid(false); - downloadsView->verticalHeader()->hide(); - downloadsView->horizontalHeader()->hide(); - downloadsView->setAlternatingRowColors(true); - downloadsView->horizontalHeader()->setStretchLastSection(true); - m_model = new DownloadModel(this); - downloadsView->setModel(m_model); - connect(cleanupButton, SIGNAL(clicked()), this, SLOT(cleanup())); - load(); -} - -DownloadManager::~DownloadManager() -{ - m_autoSaver->changeOccurred(); - m_autoSaver->saveIfNeccessary(); - if (m_iconProvider) - delete m_iconProvider; -} - -int DownloadManager::activeDownloads() const -{ - int count = 0; - for (int i = 0; i < m_downloads.count(); ++i) { - if (m_downloads.at(i)->stopButton->isEnabled()) - ++count; - } - return count; -} - -void DownloadManager::download(const QNetworkRequest &request, bool requestFileName) -{ - if (request.url().isEmpty()) - return; - handleUnsupportedContent(m_manager->get(request), requestFileName); -} - -void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool requestFileName) -{ - if (!reply || reply->url().isEmpty()) - return; - QVariant header = reply->header(QNetworkRequest::ContentLengthHeader); - bool ok; - int size = header.toInt(&ok); - if (ok && size == 0) - return; - - qDebug() << "DownloadManager::handleUnsupportedContent" << reply->url() << "requestFileName" << requestFileName; - DownloadItem *item = new DownloadItem(reply, requestFileName, this); - addItem(item); -} - -void DownloadManager::addItem(DownloadItem *item) -{ - connect(item, SIGNAL(statusChanged()), this, SLOT(updateRow())); - int row = m_downloads.count(); - m_model->beginInsertRows(QModelIndex(), row, row); - m_downloads.append(item); - m_model->endInsertRows(); - updateItemCount(); - if (row == 0) - show(); - downloadsView->setIndexWidget(m_model->index(row, 0), item); - QIcon icon = style()->standardIcon(QStyle::SP_FileIcon); - item->fileIcon->setPixmap(icon.pixmap(48, 48)); - downloadsView->setRowHeight(row, item->sizeHint().height()); -} - -void DownloadManager::updateRow() -{ - DownloadItem *item = qobject_cast(sender()); - int row = m_downloads.indexOf(item); - if (-1 == row) - return; - if (!m_iconProvider) - m_iconProvider = new QFileIconProvider(); - QIcon icon = m_iconProvider->icon(item->m_output.fileName()); - if (icon.isNull()) - icon = style()->standardIcon(QStyle::SP_FileIcon); - item->fileIcon->setPixmap(icon.pixmap(48, 48)); - downloadsView->setRowHeight(row, item->minimumSizeHint().height()); - - bool remove = false; - QWebSettings *globalSettings = QWebSettings::globalSettings(); - if (!item->downloading() - && globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) - remove = true; - - if (item->downloadedSuccessfully() - && removePolicy() == DownloadManager::SuccessFullDownload) { - remove = true; - } - if (remove) - m_model->removeRow(row); - - cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0); -} - -DownloadManager::RemovePolicy DownloadManager::removePolicy() const -{ - return m_removePolicy; -} - -void DownloadManager::setRemovePolicy(RemovePolicy policy) -{ - if (policy == m_removePolicy) - return; - m_removePolicy = policy; - m_autoSaver->changeOccurred(); -} - -void DownloadManager::save() const -{ - QSettings settings; - settings.beginGroup(QLatin1String("downloadmanager")); - QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy")); - settings.setValue(QLatin1String("removeDownloadsPolicy"), QLatin1String(removePolicyEnum.valueToKey(m_removePolicy))); - settings.setValue(QLatin1String("size"), size()); - if (m_removePolicy == Exit) - return; - - for (int i = 0; i < m_downloads.count(); ++i) { - QString key = QString(QLatin1String("download_%1_")).arg(i); - settings.setValue(key + QLatin1String("url"), m_downloads[i]->m_url); - settings.setValue(key + QLatin1String("location"), QFileInfo(m_downloads[i]->m_output).filePath()); - settings.setValue(key + QLatin1String("done"), m_downloads[i]->downloadedSuccessfully()); - } - int i = m_downloads.count(); - QString key = QString(QLatin1String("download_%1_")).arg(i); - while (settings.contains(key + QLatin1String("url"))) { - settings.remove(key + QLatin1String("url")); - settings.remove(key + QLatin1String("location")); - settings.remove(key + QLatin1String("done")); - key = QString(QLatin1String("download_%1_")).arg(++i); - } -} - -void DownloadManager::load() -{ - QSettings settings; - settings.beginGroup(QLatin1String("downloadmanager")); - QSize size = settings.value(QLatin1String("size")).toSize(); - if (size.isValid()) - resize(size); - QByteArray value = settings.value(QLatin1String("removeDownloadsPolicy"), QLatin1String("Never")).toByteArray(); - QMetaEnum removePolicyEnum = staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("RemovePolicy")); - m_removePolicy = removePolicyEnum.keyToValue(value) == -1 ? - Never : - static_cast(removePolicyEnum.keyToValue(value)); - - int i = 0; - QString key = QString(QLatin1String("download_%1_")).arg(i); - while (settings.contains(key + QLatin1String("url"))) { - QUrl url = settings.value(key + QLatin1String("url")).toUrl(); - QString fileName = settings.value(key + QLatin1String("location")).toString(); - bool done = settings.value(key + QLatin1String("done"), true).toBool(); - if (!url.isEmpty() && !fileName.isEmpty()) { - DownloadItem *item = new DownloadItem(0, this); - item->m_output.setFileName(fileName); - item->fileNameLabel->setText(QFileInfo(item->m_output.fileName()).fileName()); - item->m_url = url; - item->stopButton->setVisible(false); - item->stopButton->setEnabled(false); - item->tryAgainButton->setVisible(!done); - item->tryAgainButton->setEnabled(!done); - item->progressBar->setVisible(!done); - addItem(item); - } - key = QString(QLatin1String("download_%1_")).arg(++i); - } - cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0); -} - -void DownloadManager::cleanup() -{ - if (m_downloads.isEmpty()) - return; - m_model->removeRows(0, m_downloads.count()); - updateItemCount(); - if (m_downloads.isEmpty() && m_iconProvider) { - delete m_iconProvider; - m_iconProvider = 0; - } - m_autoSaver->changeOccurred(); -} - -void DownloadManager::updateItemCount() -{ - int count = m_downloads.count(); - itemCount->setText(count == 1 ? i18n("1 Download") : QString(count) + i18n(" Downloads") ); -} - -DownloadModel::DownloadModel(DownloadManager *downloadManager, QObject *parent) - : QAbstractListModel(parent) - , m_downloadManager(downloadManager) -{ -} - -QVariant DownloadModel::data(const QModelIndex &index, int role) const -{ - if (index.row() < 0 || index.row() >= rowCount(index.parent())) - return QVariant(); - if (role == Qt::ToolTipRole) - if (!m_downloadManager->m_downloads.at(index.row())->downloadedSuccessfully()) - return m_downloadManager->m_downloads.at(index.row())->downloadInfoLabel->text(); - return QVariant(); -} - -int DownloadModel::rowCount(const QModelIndex &parent) const -{ - return (parent.isValid()) ? 0 : m_downloadManager->m_downloads.count(); -} - -bool DownloadModel::removeRows(int row, int count, const QModelIndex &parent) -{ - if (parent.isValid()) - return false; - - int lastRow = row + count - 1; - for (int i = lastRow; i >= row; --i) { - if (m_downloadManager->m_downloads.at(i)->downloadedSuccessfully() - || m_downloadManager->m_downloads.at(i)->tryAgainButton->isEnabled()) { - beginRemoveRows(parent, i, i); - m_downloadManager->m_downloads.takeAt(i)->deleteLater(); - endRemoveRows(); - } - } - m_downloadManager->m_autoSaver->changeOccurred(); - return true; -} - diff --git a/src/downloadmanager.h b/src/downloadmanager.h deleted file mode 100644 index 1a2e5d30..00000000 --- a/src/downloadmanager.h +++ /dev/null @@ -1,142 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -#ifndef DOWNLOADMANAGER_H -#define DOWNLOADMANAGER_H - -#include "ui_downloads.h" -#include "ui_downloaditem.h" - -#include -#include -#include - - -class DownloadItem : public QWidget, public Ui_DownloadItem -{ - Q_OBJECT - -signals: - void statusChanged(); - -public: - DownloadItem(QNetworkReply *reply = 0, bool requestFileName = false, QWidget *parent = 0); - bool downloading() const; - bool downloadedSuccessfully() const; - - QUrl m_url; - - QFile m_output; - QNetworkReply *m_reply; - -private slots: - void stop(); - void tryAgain(); - void open(); - - void downloadReadyRead(); - void error(QNetworkReply::NetworkError code); - void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); - void metaDataChanged(); - void finished(); - -private: - void getFileName(); - void init(); - void updateInfoLabel(); - QString dataString(int size) const; - - QString saveFileName(const QString &directory) const; - - bool m_requestFileName; - qint64 m_bytesReceived; - QTime m_downloadTime; -}; - -class AutoSaver; -class DownloadModel; -QT_BEGIN_NAMESPACE -class QFileIconProvider; -QT_END_NAMESPACE - -class DownloadManager : public QDialog, public Ui_DownloadDialog -{ - Q_OBJECT - Q_PROPERTY(RemovePolicy removePolicy READ removePolicy WRITE setRemovePolicy) - Q_ENUMS(RemovePolicy) - -public: - enum RemovePolicy { - Never, - Exit, - SuccessFullDownload - }; - - DownloadManager(QWidget *parent = 0); - ~DownloadManager(); - int activeDownloads() const; - - RemovePolicy removePolicy() const; - void setRemovePolicy(RemovePolicy policy); - -public slots: - void download(const QNetworkRequest &request, bool requestFileName = false); - inline void download(const QUrl &url, bool requestFileName = false) - { download(QNetworkRequest(url), requestFileName); } - void handleUnsupportedContent(QNetworkReply *reply, bool requestFileName = false); - void cleanup(); - -private slots: - void save() const; - void updateRow(); - -private: - void addItem(DownloadItem *item); - void updateItemCount(); - void load(); - - AutoSaver *m_autoSaver; - DownloadModel *m_model; - QNetworkAccessManager *m_manager; - QFileIconProvider *m_iconProvider; - QList m_downloads; - RemovePolicy m_removePolicy; - friend class DownloadModel; -}; - -class DownloadModel : public QAbstractListModel -{ - friend class DownloadManager; - Q_OBJECT - -public: - DownloadModel(DownloadManager *downloadManager, QObject *parent = 0); - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - -private: - DownloadManager *m_downloadManager; - -}; - -#endif // DOWNLOADMANAGER_H - diff --git a/src/downloads.ui b/src/downloads.ui deleted file mode 100644 index a2e25693..00000000 --- a/src/downloads.ui +++ /dev/null @@ -1,83 +0,0 @@ - - DownloadDialog - - - - 0 - 0 - 332 - 252 - - - - Downloads - - - - 0 - - - 0 - - - - - - - - - - false - - - Clean up - - - - - - - Qt::Horizontal - - - - 58 - 24 - - - - - - - - - - 0 Items - - - - - - - Qt::Horizontal - - - - 148 - 20 - - - - - - - - - EditTableView - QTableView -
edittableview.h
-
-
- - -
-- cgit v1.2.1 From 05db99e424f702a4cb6a1f961870ae996250b9e5 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 20 Jan 2009 17:59:44 +0100 Subject: Updated TODO && CMakelists.txt --- TODO | 17 ++++++++--------- src/CMakeLists.txt | 3 --- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index 870e00fd..d6556087 100644 --- a/TODO +++ b/TODO @@ -11,18 +11,16 @@ ROAD to 0.0.2 (second release) - fixed search bar width ROAD to 0.0.3 (third release) -- mainview -- autosave-- && downloadSystem-- ++ mainview ++ KConfigXT +- documentation +- improve slackbuild +- autosave-- +- downloadSystem-- - dbus, kjob, kget support - new application class!! - -+ -------------------------------- -0.0.2 -+ QUrl --> KUrl -+ KDEize menubar (settings) -+ new urlbar & searchbar (for now just Google search bar..) - ++ ---------------------------------------------------- NEXT.. - system SELECT ALL @@ -30,6 +28,7 @@ NEXT.. - color progress - contextMenu in searchbar to set different search engines - KDE proxy support +- KcookieJar - QWebPluginFactory subclass to load KParts into QtWebKit. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 25c8e3cb..50fc2333 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,7 +5,6 @@ SET( rekonq_SRCS mainview.cpp tabbar.cpp cookiejar.cpp - downloadmanager.cpp edittableview.cpp edittreeview.cpp history.cpp @@ -24,8 +23,6 @@ SET( rekonq_SRCS KDE4_ADD_UI_FILES( rekonq_SRCS cookies.ui cookiesexceptions.ui - downloaditem.ui - downloads.ui history.ui passworddialog.ui proxy.ui -- cgit v1.2.1 From 504311e2a45c18e08865269985f00f7f3f3e6e8a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 20 Jan 2009 19:03:00 +0100 Subject: Implemented a new function to download data with KJob technologies.. It's not working. For now. But we are nearing the goal.. --- src/browserapplication.cpp | 55 +++++++++++++++++++++++++++++------------ src/browserapplication.h | 14 ++++++++--- src/mainwindow.cpp | 61 ++++++---------------------------------------- src/mainwindow.h | 1 - src/webview.cpp | 9 ++----- 5 files changed, 59 insertions(+), 81 deletions(-) diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index bbd4b8b1..008917e1 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -22,9 +22,10 @@ // Local Includes #include "browserapplication.h" +#include "rekonq.h" + #include "mainwindow.h" #include "cookiejar.h" -#include "downloadmanager.h" #include "history.h" #include "networkaccessmanager.h" #include "mainview.h" @@ -34,6 +35,8 @@ #include #include #include +#include +#include // Qt Includes #include @@ -49,7 +52,6 @@ -DownloadManager *BrowserApplication::s_downloadManager = 0; HistoryManager *BrowserApplication::s_historyManager = 0; NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0; @@ -103,7 +105,6 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server BrowserApplication::~BrowserApplication() { - delete s_downloadManager; qDeleteAll(m_mainWindows); delete s_networkAccessManager; } @@ -146,6 +147,41 @@ void BrowserApplication::postLaunch() } +void BrowserApplication::downloadUrl(const KUrl &url) +{ +// QString path = ReKonfig::downloadDir() + QString("/") + url.fileName(); +// KIO::NetAccess::download( url , path , mainWindow() ); + m_downloadUrl = url; + KIO::TransferJob * job = KIO::get( m_downloadUrl, KIO::NoReload); + connect(job, SIGNAL( result(KJob*) ), this, SLOT( slotResult(KJob*) ) ); + connect(job, SIGNAL(data(KIO::Job*,const QByteArray &)), this, SLOT(slotData(KIO::Job*, const QByteArray&))); +} + + +void BrowserApplication::slotResult(KJob* job) +{ + if ( job->error() ) + { + kDebug() << job->errorString(); + } + else + { + QString path = ReKonfig::downloadDir() + QString("/") + m_downloadUrl.fileName(); + QFile destFile( path ); + destFile.write(m_downloadData); + destFile.close(); + m_downloadData = 0; + } +} + + +void BrowserApplication::slotData(KIO::Job*, const QByteArray& data) +{ + m_downloadData.append(data); +} + + + QList BrowserApplication::mainWindows() { clean(); @@ -243,7 +279,7 @@ bool BrowserApplication::isTheOnlyBrowser() const void BrowserApplication::openUrl(const KUrl &url) { - mainWindow()->loadUrl( url ); + mainWindow()->loadUrl(url); } @@ -293,17 +329,6 @@ CookieJar *BrowserApplication::cookieJar() } -DownloadManager *BrowserApplication::downloadManager() -{ - if (!s_downloadManager) - { - s_downloadManager = new DownloadManager(); - } - return s_downloadManager; -} - - - NetworkAccessManager *BrowserApplication::networkAccessManager() { if (!s_networkAccessManager) diff --git a/src/browserapplication.h b/src/browserapplication.h index 4ec2cca6..7b8b98bc 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include // Qt Includes #include @@ -37,7 +40,6 @@ QT_END_NAMESPACE class MainWindow; class CookieJar; -class DownloadManager; class HistoryManager; class NetworkAccessManager; @@ -49,19 +51,18 @@ public: BrowserApplication(KCmdLineArgs*, const QString &); ~BrowserApplication(); static BrowserApplication *instance(); -// void loadSettings(); bool isTheOnlyBrowser() const; MainWindow *mainWindow(); QList mainWindows(); KIcon icon(const KUrl &url) const; + void downloadUrl(const KUrl &url); void saveSession(); bool canRestoreSession() const; static HistoryManager *historyManager(); static CookieJar *cookieJar(); - static DownloadManager *downloadManager(); static NetworkAccessManager *networkAccessManager(); public slots: @@ -72,18 +73,23 @@ private slots: void postLaunch(); void openUrl(const KUrl &url); void newLocalSocketConnection(); + void slotResult(KJob*); + void slotData(KIO::Job*, const QByteArray&); private: void clean(); static HistoryManager *s_historyManager; - static DownloadManager *s_downloadManager; static NetworkAccessManager *s_networkAccessManager; QList > m_mainWindows; QLocalServer *m_localServer; QByteArray m_lastSession; mutable KIcon m_defaultIcon; + + // about download + KUrl m_downloadUrl; + QByteArray m_downloadData; }; #endif // BROWSERAPPLICATION_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 629899e4..482c351d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -28,9 +28,10 @@ // Local Includes #include "browserapplication.h" -#include "downloadmanager.h" #include "settings.h" #include "history.h" +#include "cookiejar.h" +#include "networkaccessmanager.h" #include "bookmarks.h" #include "webview.h" @@ -194,10 +195,6 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("page source"), a ); connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewPageSource() ) ); - a = new KAction( KIcon( "kget" ), i18n("Downloads"), this ); - actionCollection()->addAction( QLatin1String("downloads"), a); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotDownloadManager() ) ); - a = new KAction( KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this ); a->setCheckable(true); actionCollection()->addAction( QLatin1String("web inspector"), a ); @@ -306,48 +303,10 @@ void MainWindow::slotUpdateConf() defaultSettings->setAttribute(QWebSettings::PluginsEnabled, arePluginsEnabled); defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, isJavascriptEnabled); -// int canAcceptCookies = ReKonfig::acceptCookies(); -// int canKeepCookiesUntil = ReKonfig::keepCookiesUntil(); -// -// CookieJar::KeepPolicy keepCookies; -// switch(canAcceptCookies) -// { -// default: -// case 0: -// keepCookies = CookieJar::KeepUntilExpire; -// break; -// case 1: -// keepCookies = CookieJar::KeepUntilExit; -// break; -// case 2: -// keepCookies = CookieJar::KeepUntilTimeLimit; -// break; -// } -// CookieJar *jar = BrowserApplication::cookieJar(); -// QMetaEnum acceptPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("AcceptPolicy")); -// -// CookieJar::KeepPolicy keepPolicy; -// switch(canKeepCookiesUntil) -// { -// default: -// case 0: -// keepPolicy = CookieJar::KeepUntilExpire; -// break; -// case 1: -// keepPolicy = CookieJar::KeepUntilExit; -// break; -// case 2: -// keepPolicy = CookieJar::KeepUntilTimeLimit; -// break; -// } -// -// QMetaEnum keepPolicyEnum = jar->staticMetaObject.enumerator(jar->staticMetaObject.indexOfEnumerator("KeepPolicy")); -// // --- -// BrowserApplication::instance()->loadSettings(); -// BrowserApplication::networkAccessManager()->loadSettings(); -// BrowserApplication::cookieJar()->loadSettings(); -// BrowserApplication::historyManager()->loadSettings(); - + // load Settings on main classes + BrowserApplication::networkAccessManager()->loadSettings(); + BrowserApplication::cookieJar()->loadSettings(); + BrowserApplication::historyManager()->loadSettings(); } @@ -416,12 +375,6 @@ void MainWindow::loadUrl(const KUrl &url) } -void MainWindow::slotDownloadManager() -{ - BrowserApplication::downloadManager()->show(); -} - - void MainWindow::slotOpenLocation() { m_view->currentLineEdit()->selectAll(); @@ -431,7 +384,7 @@ void MainWindow::slotOpenLocation() void MainWindow::slotFileSaveAs() { - BrowserApplication::downloadManager()->download(currentTab()->url(), true); + BrowserApplication::instance()->downloadUrl( currentTab()->url() ); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 86a3e30d..8b8f1cbe 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -110,7 +110,6 @@ private slots: // Tools Menu slots void slotToggleInspector(bool enable); - void slotDownloadManager(); // Settings Menu slots void slotPreferences(); diff --git a/src/webview.cpp b/src/webview.cpp index adfeab97..c7202fd8 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -30,13 +30,11 @@ #include "mainwindow.h" #include "mainview.h" #include "cookiejar.h" -#include "downloadmanager.h" #include "networkaccessmanager.h" // KDE Includes #include #include -#include // Qt Includes #include @@ -126,7 +124,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { if (reply->error() == QNetworkReply::NoError) { - BrowserApplication::downloadManager()->handleUnsupportedContent(reply); + BrowserApplication::instance()->downloadUrl( reply->url() ); return; } @@ -305,12 +303,9 @@ void WebView::setStatusBarText(const QString &string) } -// FIXME: use KIO transfer job instead!! void WebView::downloadRequested(const QNetworkRequest &request) { - const KUrl url = KUrl( request.url() ); - QString path = ReKonfig::downloadDir() + QString("/") + url.fileName(); - KIO::NetAccess::download( url , path , this ); + BrowserApplication::instance()->downloadUrl( request.url() ); } -- cgit v1.2.1 From 22bc40e17d463ec817a9c9c1f461b4f7990c5450 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 21 Jan 2009 02:03:30 +0100 Subject: Reimplemented download system based on KGet one. Thanks Lucas ;) Rekonq now has its one! --- src/CMakeLists.txt | 3 +- src/browserapplication.cpp | 34 ++----------------- src/browserapplication.h | 8 +---- src/download.cpp | 82 ++++++++++++++++++++++++++++++++++++++++++++++ src/download.h | 56 +++++++++++++++++++++++++++++++ src/mainwindow.cpp | 5 ++- src/webview.cpp | 10 ++++-- 7 files changed, 156 insertions(+), 42 deletions(-) create mode 100644 src/download.cpp create mode 100644 src/download.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50fc2333..b18f6275 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,7 +7,8 @@ SET( rekonq_SRCS cookiejar.cpp edittableview.cpp edittreeview.cpp - history.cpp + history.cpp + download.cpp bookmarks.cpp modelmenu.cpp networkaccessmanager.cpp diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp index 008917e1..a82b095c 100644 --- a/src/browserapplication.cpp +++ b/src/browserapplication.cpp @@ -30,6 +30,7 @@ #include "networkaccessmanager.h" #include "mainview.h" #include "webview.h" +#include "download.h" // KDE Includes #include @@ -147,41 +148,12 @@ void BrowserApplication::postLaunch() } -void BrowserApplication::downloadUrl(const KUrl &url) +void BrowserApplication::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) { -// QString path = ReKonfig::downloadDir() + QString("/") + url.fileName(); -// KIO::NetAccess::download( url , path , mainWindow() ); - m_downloadUrl = url; - KIO::TransferJob * job = KIO::get( m_downloadUrl, KIO::NoReload); - connect(job, SIGNAL( result(KJob*) ), this, SLOT( slotResult(KJob*) ) ); - connect(job, SIGNAL(data(KIO::Job*,const QByteArray &)), this, SLOT(slotData(KIO::Job*, const QByteArray&))); + new Download( srcUrl, destUrl ); } -void BrowserApplication::slotResult(KJob* job) -{ - if ( job->error() ) - { - kDebug() << job->errorString(); - } - else - { - QString path = ReKonfig::downloadDir() + QString("/") + m_downloadUrl.fileName(); - QFile destFile( path ); - destFile.write(m_downloadData); - destFile.close(); - m_downloadData = 0; - } -} - - -void BrowserApplication::slotData(KIO::Job*, const QByteArray& data) -{ - m_downloadData.append(data); -} - - - QList BrowserApplication::mainWindows() { clean(); diff --git a/src/browserapplication.h b/src/browserapplication.h index 7b8b98bc..9b47bfcc 100644 --- a/src/browserapplication.h +++ b/src/browserapplication.h @@ -56,7 +56,7 @@ public: MainWindow *mainWindow(); QList mainWindows(); KIcon icon(const KUrl &url) const; - void downloadUrl(const KUrl &url); + void downloadUrl(const KUrl &srcUrl, const KUrl &destUrl); void saveSession(); bool canRestoreSession() const; @@ -73,8 +73,6 @@ private slots: void postLaunch(); void openUrl(const KUrl &url); void newLocalSocketConnection(); - void slotResult(KJob*); - void slotData(KIO::Job*, const QByteArray&); private: void clean(); @@ -86,10 +84,6 @@ private: QLocalServer *m_localServer; QByteArray m_lastSession; mutable KIcon m_defaultIcon; - - // about download - KUrl m_downloadUrl; - QByteArray m_downloadData; }; #endif // BROWSERAPPLICATION_H diff --git a/src/download.cpp b/src/download.cpp new file mode 100644 index 00000000..aedd0a63 --- /dev/null +++ b/src/download.cpp @@ -0,0 +1,82 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007 Lukas Appelhans + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +// local Includes +#include "download.h" +#include "download.moc" + +// KDE Includes +#include + +// Qt Includes +#include +#include + +Download::Download(const KUrl &srcUrl, const KUrl &destUrl) + : m_srcUrl(srcUrl), + m_destUrl(destUrl) +{ + kDebug(5001) << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); + m_copyJob = KIO::get(m_srcUrl); + connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); + connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); +} + +Download::~Download() +{ +} + +void Download::slotData(KIO::Job *job, const QByteArray& data) +{ + Q_UNUSED(job); + m_data.append(data); +} + +void Download::slotResult(KJob * job) +{ + kDebug(5001); + switch (job->error()) + { + case 0://The download has finished + { + kDebug(5001) << "Downloading successfully finished" << m_destUrl.url(); + QFile torrentFile(m_destUrl.path()); + if (!torrentFile.open(QIODevice::WriteOnly | QIODevice::Text)) {} + torrentFile.write(m_data); + torrentFile.close(); + emit finishedSuccessfully(m_destUrl, m_data); + m_data = 0; + break; + } + case KIO::ERR_FILE_ALREADY_EXIST: + { + kDebug(5001) << "ERROR - File already exists"; + QFile file(m_destUrl.path()); + emit finishedSuccessfully(m_destUrl, file.readAll()); + m_data = 0; + break; + } + default: + kDebug(5001) << "We are sorry to say you, that there were errors while downloading :("; + m_data = 0; + emit finishedWithError(); + break; + } +} diff --git a/src/download.h b/src/download.h new file mode 100644 index 00000000..7986341d --- /dev/null +++ b/src/download.h @@ -0,0 +1,56 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007 Lukas Appelhans + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + +#ifndef DOWNLOAD_H +#define DOWNLOAD_H + +// KDE Includes +#include +#include + +// Qt Includes +#include +#include + + +class Download : public QObject +{ + Q_OBJECT + public: + Download(const KUrl &srcUrl, const KUrl &destUrl); + ~Download(); + + Q_SIGNALS: + void finishedSuccessfully(KUrl dest, QByteArray data); + void finishedWithError(); + + private slots: + void slotResult(KJob * job); + void slotData(KIO::Job *job, const QByteArray& data); + + private: + KIO::TransferJob *m_copyJob; + KUrl m_srcUrl; + KUrl m_destUrl; + KUrl m_destFile; + QByteArray m_data; +}; + +#endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 482c351d..7a7ec427 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -384,7 +384,10 @@ void MainWindow::slotOpenLocation() void MainWindow::slotFileSaveAs() { - BrowserApplication::instance()->downloadUrl( currentTab()->url() ); + KUrl srcUrl = currentTab()->url(); + QString destPath = KFileDialog::getSaveFileName(); + KUrl destUrl = KUrl(destPath); + BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); } diff --git a/src/webview.cpp b/src/webview.cpp index c7202fd8..436db54e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -124,7 +124,10 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { if (reply->error() == QNetworkReply::NoError) { - BrowserApplication::instance()->downloadUrl( reply->url() ); + KUrl srcUrl = reply->url(); + QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); + KUrl destUrl = KUrl(path); + BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); return; } @@ -305,7 +308,10 @@ void WebView::setStatusBarText(const QString &string) void WebView::downloadRequested(const QNetworkRequest &request) { - BrowserApplication::instance()->downloadUrl( request.url() ); + KUrl srcUrl = request.url(); + QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); + KUrl destUrl = KUrl(path); + BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); } -- cgit v1.2.1 From 96bd94c88f238fe06ddf5e772bcbe084405cc252 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 27 Jan 2009 01:41:30 +0100 Subject: 1st introduction of new bookmarks line --- src/bookmarks.cpp | 8 ++++++++ src/bookmarks.h | 10 ++++++++++ src/rekonqui.rc | 7 +++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 3cb65e38..a83fbdab 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -69,3 +69,11 @@ BookmarksMenu::BookmarksMenu(KMainWindow *parent) m_menu = new KBookmarkMenu( m_manager , m_owner, this, m_ac ); } + + +//--------------------------------------------------------------------------------------------------------------------- + + +BookmarksLine::BookmarksLine(QObject *parent, KToolBar *toolbar) +{ +} diff --git a/src/bookmarks.h b/src/bookmarks.h index e0e49c78..490f8ee2 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -50,6 +50,7 @@ private: MainWindow *m_parent; }; +// ------------------------------------------------------------------------------ class BookmarksMenu : public KMenu { @@ -64,5 +65,14 @@ private: KBookmarkMenu *m_menu; }; +// ------------------------------------------------------------------------------ + +class BookmarksLine : public QObject +{ +Q_OBJECT +public: + BookmarksLine(QObject *parent, KToolBar *toolbar); + +}; #endif diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 3a9ab682..4e2c766e 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -71,7 +71,6 @@ - Main Toolbar @@ -79,4 +78,8 @@ + +Bookmarks Toolbar + + -- cgit v1.2.1 From feb5472021e697aa2722806a4a46ec56dfa1579f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 27 Jan 2009 12:21:11 +0100 Subject: We now have the FINAL search bar!! Yeah!!! --- TODO | 2 ++ src/findbar.cpp | 54 ++++++++++++++++++++++++++++++++++-------------------- src/findbar.h | 5 ++--- src/mainwindow.cpp | 25 +++++++++++++++++-------- 4 files changed, 55 insertions(+), 31 deletions(-) diff --git a/TODO b/TODO index d6556087..1f106dae 100644 --- a/TODO +++ b/TODO @@ -20,6 +20,8 @@ ROAD to 0.0.3 (third release) - dbus, kjob, kget support - new application class!! +---- REMOVE ALL FOCUS TO QStackedWidget in mainview!! + + ---------------------------------------------------- NEXT.. diff --git a/src/findbar.cpp b/src/findbar.cpp index 6ba310ca..e3f4b231 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -33,33 +33,47 @@ #include -FindBar::FindBar(KXmlGuiWindow *parent) - : KToolBar( "findBar" , parent, Qt::BottomToolBarArea, true, false, false) +FindBar::FindBar(KXmlGuiWindow *mainwindow) + : QWidget() , m_lineEdit(0) { - KAction *close = new KAction(KIcon("dialog-close") , "close" , this); - connect( close , SIGNAL( triggered() ), this, SLOT( hide() ) ); - addAction( close ); + QHBoxLayout *layout = new QHBoxLayout; - QLabel *label = new QLabel("Find: "); - addWidget( label ); + // cosmetic + layout->setMargin(2); + + // hide button + QToolButton *hideButton = new QToolButton(this); + hideButton->setAutoRaise(true); + hideButton->setIcon(KIcon("dialog-close")); + connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); + layout->addWidget(hideButton); + layout->setAlignment( hideButton, Qt::AlignLeft|Qt::AlignTop ); - m_lineEdit = new KLineEdit(); - m_lineEdit->setMaximumWidth( 200 ); + // label + QLabel *label = new QLabel("Find: "); + layout->addWidget(label); - connect( m_lineEdit, SIGNAL( returnPressed() ), parent, SLOT( slotFindNext() ) ); - connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), parent, SLOT( slotFindNext() ) ); - addWidget( m_lineEdit ); + // lineEdit, focusProxy + m_lineEdit = new KLineEdit(this); + setFocusProxy(m_lineEdit); + m_lineEdit->setMaximumWidth( 250 ); + connect( m_lineEdit, SIGNAL( returnPressed() ), mainwindow, SLOT( slotFindNext() ) ); + connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), mainwindow, SLOT( slotFindNext() ) ); + layout->addWidget( m_lineEdit ); + // buttons KPushButton *findNext = new KPushButton( KIcon("go-down"), "&Next", this ); KPushButton *findPrev = new KPushButton( KIcon("go-up"), "&Previous", this ); - // perhaps we don't need working on style.. -// findNext->setStyle(); -// findPrev->setStyle(); - connect( findNext, SIGNAL( clicked() ), parent, SLOT( slotFindNext() ) ); - connect( findPrev, SIGNAL( clicked() ), parent, SLOT( slotFindPrevious() ) ); - addWidget( findNext ); - addWidget( findPrev ); + connect( findNext, SIGNAL( clicked() ), mainwindow, SLOT( slotFindNext() ) ); + connect( findPrev, SIGNAL( clicked() ), mainwindow, SLOT( slotFindPrevious() ) ); + layout->addWidget( findNext ); + layout->addWidget( findPrev ); + + // stretching widget on the left + layout->addStretch(); + + setLayout(layout); // we start off hidden hide(); @@ -102,7 +116,7 @@ void FindBar::keyPressEvent(QKeyEvent* event) hide(); return; } - if(event->key() == Qt::Key_Return && ! ( m_lineEdit->text().isEmpty() ) ) + if(event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty() ) { emit searchString( m_lineEdit->text() ); return; diff --git a/src/findbar.h b/src/findbar.h index d70a9de1..f2c59ce9 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -25,12 +25,12 @@ #include #include -class FindBar : public KToolBar +class FindBar : public QWidget // KateViewHelpers.h { Q_OBJECT public: - FindBar(KXmlGuiWindow *parent); + FindBar(KXmlGuiWindow *mainwindow); ~FindBar(); KLineEdit *lineEdit(); @@ -46,7 +46,6 @@ signals: private: KLineEdit *m_lineEdit; - QWidget *m_centralWidget; }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7a7ec427..10d6f8ce 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -57,6 +57,7 @@ #include #include #include +#include MainWindow::MainWindow() @@ -73,8 +74,18 @@ MainWindow::MainWindow() // creating a new tab m_view->newTab(); - // tell the KXmlGuiWindow that this is indeed the main widget - setCentralWidget(m_view); + // creating a centralWidget containing m_view and the hidden findbar + QWidget *centralWidget = new QWidget; + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(m_view); + + // Find Bar + m_findBar = new FindBar(this); + connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); + layout->addWidget(m_findBar); + + centralWidget->setLayout(layout); + setCentralWidget(centralWidget); // connect signals and slots connect(m_view, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); @@ -116,10 +127,6 @@ MainWindow::MainWindow() m_searchBar = new SearchBar( this ); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); navigationBar->addWidget(m_searchBar); - - // Find Bar - m_findBar = new FindBar( this ); - connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); } @@ -543,7 +550,9 @@ void MainWindow::slotFind(const QString & search) { m_lastSearch = search; if (!currentTab()->findText(m_lastSearch)) + { slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + } } } @@ -556,7 +565,7 @@ void MainWindow::slotViewFindBar() void MainWindow::slotFindNext() { - if (!currentTab() && !m_lastSearch.isEmpty()) + if (!currentTab() && m_lastSearch.isEmpty()) return; currentTab()->findText(m_lastSearch); } @@ -564,7 +573,7 @@ void MainWindow::slotFindNext() void MainWindow::slotFindPrevious() { - if (!currentTab() && !m_lastSearch.isEmpty()) + if (!currentTab() && m_lastSearch.isEmpty()) return; currentTab()->findText(m_lastSearch, QWebPage::FindBackward); } -- cgit v1.2.1 From de1b2a26f7eaebd3fa1fa2eeb30f4e26afb534fe Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 27 Jan 2009 17:33:26 +0100 Subject: Fixed MenuBar. Fixed BookmarkLine in rekonqui.rc Now we need just the code to implement it.. --- src/bookmarks.cpp | 12 ++++++------ src/bookmarks.h | 8 +++++--- src/mainwindow.cpp | 24 ++++++++++++++---------- src/mainwindow.h | 5 ++++- src/rekonqui.rc | 18 ++++-------------- 5 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index a83fbdab..08ece82a 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -58,22 +58,22 @@ QString OwnBookMarks::currentTitle() const //--------------------------------------------------------------------------------------------------------------------- -BookmarksMenu::BookmarksMenu(KMainWindow *parent) +BookmarksMenu::BookmarksMenu(KMainWindow *parent, KBookmarkManager *manager) : KMenu(parent) - , m_owner( new OwnBookMarks( parent ) ) + , m_owner( new OwnBookMarks(parent) ) { - KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks - m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); +// KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks +// m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); m_ac = new KActionCollection( this ); - m_menu = new KBookmarkMenu( m_manager , m_owner, this, m_ac ); + m_menu = new KBookmarkMenu( manager , m_owner, this, m_ac ); } //--------------------------------------------------------------------------------------------------------------------- -BookmarksLine::BookmarksLine(QObject *parent, KToolBar *toolbar) +BookmarksLine::BookmarksLine(KBookmarkManager *manager, KToolBar *toolbar) { } diff --git a/src/bookmarks.h b/src/bookmarks.h index 490f8ee2..5aa384a1 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -56,10 +56,9 @@ class BookmarksMenu : public KMenu { Q_OBJECT public: - BookmarksMenu(KMainWindow * parent); + BookmarksMenu(KMainWindow*, KBookmarkManager *); private: - KBookmarkManager *m_manager; OwnBookMarks *m_owner; KActionCollection *m_ac; KBookmarkMenu *m_menu; @@ -71,8 +70,11 @@ class BookmarksLine : public QObject { Q_OBJECT public: - BookmarksLine(QObject *parent, KToolBar *toolbar); + BookmarksLine(KBookmarkManager *, KToolBar *toolbar); +private: + OwnBookMarks *m_owner; + KActionCollection *m_ac; }; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 10d6f8ce..0d93ea60 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -63,6 +63,7 @@ MainWindow::MainWindow() : KXmlGuiWindow() , m_view( new MainView(this) ) + , m_manager(0) { // accept dnd setAcceptDrops(true); @@ -107,6 +108,16 @@ MainWindow::MainWindow() // add a status bar statusBar()->show(); + // ----- BOOKMARKS MENU: this has to be done BEFORE setupGUI!! + KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks + m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); + + KAction *a = new KActionMenu( i18n("B&ookmarks"), this ); + actionCollection()->addAction( QLatin1String("bookmarks"), a ); + BookmarksMenu *bookmarksMenu = new BookmarksMenu( this, m_manager ); + a->setMenu( bookmarksMenu ); + + // a call to KXmlGuiWindow::setupGUI() populates the GUI // with actions, using KXMLGUI. // It also applies the saved mainwindow settings, if any, and ask the @@ -114,8 +125,8 @@ MainWindow::MainWindow() // toolbar position, icon size, etc. setupGUI(); - // setup history & bookmarks menus - setupCustomMenu(); + // setup history menu + setupHistoryMenu(); // setup Tab Bar setupTabBar(); @@ -207,12 +218,6 @@ void MainWindow::setupActions() actionCollection()->addAction( QLatin1String("web inspector"), a ); connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotToggleInspector(bool) ) ); - // ================== BOOKMARKS MENU - a = new KActionMenu( i18n("B&ookmarks"), this ); - actionCollection()->addAction( QLatin1String("bookmarks"), a ); - BookmarksMenu *bookmarksMenu = new BookmarksMenu( this ); - a->setMenu( bookmarksMenu ); - // ================ history related actions KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); @@ -267,9 +272,8 @@ void MainWindow::setupTabBar() } -void MainWindow::setupCustomMenu() +void MainWindow::setupHistoryMenu() { - // -------------------------------- HISTORY MENU ----------------------------------------------------------------------- HistoryMenu *historyMenu = new HistoryMenu(this); connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_view, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); diff --git a/src/mainwindow.h b/src/mainwindow.h index 8b8f1cbe..476a6fe6 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -26,6 +26,7 @@ #include "findbar.h" #include "searchbar.h" #include "mainview.h" +#include "bookmarks.h" // KDE Includes #include @@ -61,7 +62,7 @@ public: private: void setupActions(); - void setupCustomMenu(); + void setupHistoryMenu(); void setupTabBar(); public slots: @@ -121,6 +122,8 @@ private: KMenu *m_historyBackMenu; KMenu *m_windowMenu; + KBookmarkManager *m_manager; + QAction *m_stopReload; QString m_lastSearch; diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 4e2c766e..256d59b2 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -44,7 +44,6 @@ - @@ -57,17 +56,8 @@ - - &Settings - - - - - - + + @@ -79,7 +69,7 @@ -Bookmarks Toolbar +Bookmarks Toolbar -- cgit v1.2.1 From 1024f77ad03ef3d30d8be6aa61542a057a100868 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 28 Jan 2009 00:59:08 +0100 Subject: Removed unuseful "Select All" action. If someone needs it, I can try to implement it one day.. --- src/mainview.cpp | 8 -------- src/mainview.h | 1 - src/mainwindow.cpp | 3 ++- src/mainwindow.h | 5 ++--- src/rekonqui.rc | 4 +--- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index 328d3dd1..acef1998 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -171,14 +171,6 @@ void MainView::slotWebPaste() } -void MainView::slotWebSelectAll() -{ - WebView *webView = currentWebView(); - QWebPage *currentParent = webView->webPage(); - // TODO -} - - void MainView::clear() { // clear the recently closed tabs diff --git a/src/mainview.h b/src/mainview.h index 1bb0bf6e..1f443a37 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -112,7 +112,6 @@ public slots: void slotWebCut(); void slotWebCopy(); void slotWebPaste(); - void slotWebSelectAll(); private slots: void currentChanged(int index); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0d93ea60..d956642b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -34,6 +34,8 @@ #include "networkaccessmanager.h" #include "bookmarks.h" #include "webview.h" +#include "mainview.h" +#include "bookmarks.h" // UI Includes #include "ui_passworddialog.h" @@ -173,7 +175,6 @@ void MainWindow::setupActions() KStandardAction::cut( m_view, SLOT( slotWebCut() ), actionCollection() ); KStandardAction::copy( m_view, SLOT( slotWebCopy() ), actionCollection() ); KStandardAction::paste( m_view, SLOT( slotWebPaste() ), actionCollection() ); - KStandardAction::selectAll( m_view, SLOT( slotWebSelectAll() ), actionCollection() ); a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); diff --git a/src/mainwindow.h b/src/mainwindow.h index 476a6fe6..d1eba1a4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -25,8 +25,6 @@ // Local Includes #include "findbar.h" #include "searchbar.h" -#include "mainview.h" -#include "bookmarks.h" // KDE Includes #include @@ -37,7 +35,8 @@ #include #include - +class KBookmarkManager; +class MainView; class QWebFrame; class WebView; diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 256d59b2..11897e03 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -28,8 +28,6 @@ - - -- cgit v1.2.1 From dc7cc2d262903aac402b7b1841b61d111ce797e8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 28 Jan 2009 01:00:15 +0100 Subject: SOme more bits on bookmarkline.. --- src/bookmarks.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 08ece82a..a736e378 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -62,11 +62,7 @@ BookmarksMenu::BookmarksMenu(KMainWindow *parent, KBookmarkManager *manager) : KMenu(parent) , m_owner( new OwnBookMarks(parent) ) { -// KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks -// m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); - m_ac = new KActionCollection( this ); - m_menu = new KBookmarkMenu( manager , m_owner, this, m_ac ); } @@ -76,4 +72,11 @@ BookmarksMenu::BookmarksMenu(KMainWindow *parent, KBookmarkManager *manager) BookmarksLine::BookmarksLine(KBookmarkManager *manager, KToolBar *toolbar) { + KBookmarkGroup toolbarGroup = manager->toolbar(); + KBookmark bm = toolbarGroup.first(); + while(!bm.isNull()) + { + // TODO append bm to toolbar + bm = toolbarGroup.next(bm); + } } -- cgit v1.2.1 From b18c3e2085ef29874ea77141c293902be67ca114 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 28 Jan 2009 14:24:15 +0100 Subject: updated Changelog && TODO --- ChangeLog | 8 ++++++++ TODO | 13 +++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e858a26..49e7930f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +0.0.3 +- ~80% ported to KDE4 +- KConfigXT support +- improved text search bar +- fixed all "web actions" +- adopted KDE download system +- new bookmark toolbar + 0.0.2 - 70% ported to KDE4 - new urlbar diff --git a/TODO b/TODO index 1f106dae..787aca3e 100644 --- a/TODO +++ b/TODO @@ -13,19 +13,20 @@ ROAD to 0.0.2 (second release) ROAD to 0.0.3 (third release) + mainview + KConfigXT -- documentation -- improve slackbuild ++ downloadSystem-- +- documentation++ - autosave-- -- downloadSystem-- -- dbus, kjob, kget support +- dbus support - new application class!! ----- REMOVE ALL FOCUS TO QStackedWidget in mainview!! +--- REMOVE ALL FOCUS TO QStackedWidget in mainview!! +--- improve searchbar features +--- bookmarks line + ---------------------------------------------------- NEXT.. -- system SELECT ALL ++ system SELECT ALL - better FULL SCREEN - color progress - contextMenu in searchbar to set different search engines -- cgit v1.2.1 From 8d95276b0e734a06836806fe84ab3f2ea4f5b252 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 28 Jan 2009 15:57:59 +0100 Subject: updated TODO --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index 787aca3e..3e3cecf7 100644 --- a/TODO +++ b/TODO @@ -22,6 +22,7 @@ ROAD to 0.0.3 (third release) --- REMOVE ALL FOCUS TO QStackedWidget in mainview!! --- improve searchbar features --- bookmarks line +--- fix sessions && ui dimension + ---------------------------------------------------- -- cgit v1.2.1 From d467ccf90fb3e8c851db97c44f551aeaa9fa289f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 28 Jan 2009 15:58:37 +0100 Subject: New BookmarkBar!! 1st version, Yeah!! --- src/bookmarks.cpp | 47 ++++++++++++++++++++++++++++++++++++----------- src/bookmarks.h | 25 ++++++++----------------- src/mainwindow.cpp | 14 +++++++------- src/mainwindow.h | 4 ++-- src/rekonqui.rc | 6 +++--- 5 files changed, 56 insertions(+), 40 deletions(-) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index a736e378..584b2689 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -26,6 +26,7 @@ // KDE Includes #include +#include OwnBookMarks::OwnBookMarks(KMainWindow *parent) : QObject(parent) @@ -55,28 +56,52 @@ QString OwnBookMarks::currentTitle() const } -//--------------------------------------------------------------------------------------------------------------------- +// ------------------------------------------------------------------------------------------------------ -BookmarksMenu::BookmarksMenu(KMainWindow *parent, KBookmarkManager *manager) - : KMenu(parent) - , m_owner( new OwnBookMarks(parent) ) +BookmarksProvider::BookmarksProvider(KMainWindow* parent) + : m_parent(parent) + , m_owner(new OwnBookMarks(parent)) { + KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks + m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); m_ac = new KActionCollection( this ); - m_menu = new KBookmarkMenu( manager , m_owner, this, m_ac ); } -//--------------------------------------------------------------------------------------------------------------------- - - -BookmarksLine::BookmarksLine(KBookmarkManager *manager, KToolBar *toolbar) +void BookmarksProvider::provideBmToolbar(KToolBar* toolbar) { - KBookmarkGroup toolbarGroup = manager->toolbar(); + toolbar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); + KBookmarkGroup toolbarGroup = m_manager->toolbar(); KBookmark bm = toolbarGroup.first(); while(!bm.isNull()) { - // TODO append bm to toolbar + if(bm.isGroup()) + { + // do nothing! + } + else + { + if(bm.isSeparator()) + { + toolbar->addSeparator(); + } + else + { + KAction *a = new KBookmarkAction(bm, m_owner, m_ac); + toolbar->addAction(a); + } + } + // go ahead! bm = toolbarGroup.next(bm); } } + + +KMenu *BookmarksProvider::bookmarksMenu() +{ + KMenu *bmMenu = new KMenu(m_parent); + new KBookmarkMenu( m_manager, m_owner, bmMenu, m_ac ); + return bmMenu; +} + diff --git a/src/bookmarks.h b/src/bookmarks.h index 5aa384a1..2bdfab0a 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -35,7 +36,7 @@ class OwnBookMarks : public QObject , public KBookmarkOwner { Q_OBJECT public: - OwnBookMarks(KMainWindow * ); + OwnBookMarks(KMainWindow *); virtual void openBookmark (const KBookmark & , Qt::MouseButtons , Qt::KeyboardModifiers ); @@ -52,29 +53,19 @@ private: // ------------------------------------------------------------------------------ -class BookmarksMenu : public KMenu +class BookmarksProvider : public QObject { Q_OBJECT public: - BookmarksMenu(KMainWindow*, KBookmarkManager *); + BookmarksProvider(KMainWindow*); -private: - OwnBookMarks *m_owner; - KActionCollection *m_ac; - KBookmarkMenu *m_menu; -}; - -// ------------------------------------------------------------------------------ - -class BookmarksLine : public QObject -{ -Q_OBJECT -public: - BookmarksLine(KBookmarkManager *, KToolBar *toolbar); + void provideBmToolbar(KToolBar*); + KMenu *bookmarksMenu(); private: + KMainWindow *m_parent; OwnBookMarks *m_owner; + KBookmarkManager *m_manager; KActionCollection *m_ac; }; - #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d956642b..87ae0ac0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -50,6 +50,7 @@ #include #include #include +#include // Qt Includes #include @@ -65,7 +66,7 @@ MainWindow::MainWindow() : KXmlGuiWindow() , m_view( new MainView(this) ) - , m_manager(0) + , m_bookmarksProvider( new BookmarksProvider(this) ) { // accept dnd setAcceptDrops(true); @@ -111,14 +112,10 @@ MainWindow::MainWindow() statusBar()->show(); // ----- BOOKMARKS MENU: this has to be done BEFORE setupGUI!! - KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks - m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); - KAction *a = new KActionMenu( i18n("B&ookmarks"), this ); actionCollection()->addAction( QLatin1String("bookmarks"), a ); - BookmarksMenu *bookmarksMenu = new BookmarksMenu( this, m_manager ); - a->setMenu( bookmarksMenu ); - + KMenu *bmMenu = m_bookmarksProvider->bookmarksMenu(); + a->setMenu( bmMenu ); // a call to KXmlGuiWindow::setupGUI() populates the GUI // with actions, using KXMLGUI. @@ -137,6 +134,9 @@ MainWindow::MainWindow() KToolBar *navigationBar = toolBar( "mainToolBar" ); navigationBar->addWidget( m_view->lineEditStack() ); + KToolBar *bmToolbar = toolBar("bookmarksToolBar"); + m_bookmarksProvider->provideBmToolbar( bmToolbar ); + m_searchBar = new SearchBar( this ); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); navigationBar->addWidget(m_searchBar); diff --git a/src/mainwindow.h b/src/mainwindow.h index d1eba1a4..2ec5c1bd 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -35,7 +35,7 @@ #include #include -class KBookmarkManager; +class BookmarksProvider; class MainView; class QWebFrame; class WebView; @@ -121,7 +121,7 @@ private: KMenu *m_historyBackMenu; KMenu *m_windowMenu; - KBookmarkManager *m_manager; + BookmarksProvider *m_bookmarksProvider; QAction *m_stopReload; diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 11897e03..5016192f 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -59,7 +59,7 @@ -Main Toolbar +Main Toolbar @@ -67,7 +67,7 @@ -Bookmarks Toolbar +Bookmarks Toolbar -- cgit v1.2.1 From 2649aba801efdbf57f10b55a5e6c46dbd13cdbb4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 29 Jan 2009 10:52:28 +0100 Subject: Fixed Find bar use. --- TODO | 3 ++- src/findbar.cpp | 4 ++-- src/mainwindow.cpp | 20 ++++++++++---------- src/rekonqui.rc | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/TODO b/TODO index 3e3cecf7..e8fa7215 100644 --- a/TODO +++ b/TODO @@ -21,8 +21,9 @@ ROAD to 0.0.3 (third release) --- REMOVE ALL FOCUS TO QStackedWidget in mainview!! --- improve searchbar features ---- bookmarks line +++- bookmarks line --- fix sessions && ui dimension +--- fix KConfigXT use + ---------------------------------------------------- diff --git a/src/findbar.cpp b/src/findbar.cpp index e3f4b231..449e24fa 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -58,8 +58,8 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) m_lineEdit = new KLineEdit(this); setFocusProxy(m_lineEdit); m_lineEdit->setMaximumWidth( 250 ); - connect( m_lineEdit, SIGNAL( returnPressed() ), mainwindow, SLOT( slotFindNext() ) ); - connect( m_lineEdit, SIGNAL( textEdited(const QString &) ), mainwindow, SLOT( slotFindNext() ) ); +// connect( m_lineEdit, SIGNAL( returnPressed() ), mainwindow, SLOT( slotFind() ) ); + connect( m_lineEdit, SIGNAL( textChanged(const QString &) ), mainwindow, SLOT( slotFind(const QString &) ) ); layout->addWidget( m_lineEdit ); // buttons diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 87ae0ac0..c7c1a47e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -551,14 +551,8 @@ void MainWindow::slotFind(const QString & search) { if (!currentTab()) return; - if (!search.isEmpty()) - { - m_lastSearch = search; - if (!currentTab()->findText(m_lastSearch)) - { - slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); - } - } + m_lastSearch = search; + slotFindNext(); } @@ -572,7 +566,10 @@ void MainWindow::slotFindNext() { if (!currentTab() && m_lastSearch.isEmpty()) return; - currentTab()->findText(m_lastSearch); + if (!currentTab()->findText(m_lastSearch, QWebPage::FindWrapsAroundDocument)) + { + slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + } } @@ -580,7 +577,10 @@ void MainWindow::slotFindPrevious() { if (!currentTab() && m_lastSearch.isEmpty()) return; - currentTab()->findText(m_lastSearch, QWebPage::FindBackward); + if (!currentTab()->findText(m_lastSearch, QWebPage::FindBackward)) + { + slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + } } diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 5016192f..861f8538 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -67,7 +67,7 @@ -Bookmarks Toolbar +Bookmarks Toolbar -- cgit v1.2.1 From dd0c4480eec6e12665aef9991c92cb80cc9e6a12 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 29 Jan 2009 11:59:07 +0100 Subject: 1st lines of docs --- doc/index.docbook | 63 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/doc/index.docbook b/doc/index.docbook index e9b64bd5..6eb4cd25 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -3,7 +3,7 @@ rekonq"> - -The &kmyapplication; Handbook +The &rekonq; Handbook @@ -63,11 +63,10 @@ as Authors, publish date, the abstract, and Keywords --> and use `&George.N.Ugnacious; &George.N.Ugnacious.mail;' in the author element. --> -George -N. -Ugnacious +Andrea +Diamantini -gnu@kde.org +adjam7@gmail.com @@ -75,7 +74,7 @@ and use `&George.N.Ugnacious; &George.N.Ugnacious.mail;' in the author element. 2008 -George N. Ugnacious +Andrea Diamantini -2008-01-10 -1.01.00 +2008-12-01 +0.00.03 -&kmyapplication; is an application specially designed to do nothing you would +&rekonq; is an application specially designed to do nothing you would ever want. @@ -107,10 +106,10 @@ Please at least include KDE, the KDE package it is in, the name KDE -kdeutils -Kapp -nothing -nothing else +kdenetwork +rekonq +webkit +browser @@ -133,13 +132,13 @@ problems. Basically a long version of the abstract. Don't include a revision history. (see installation appendix comment) --> -&kmyapplication; is a program that lets you do absolutely nothing. Please report +&rekonq; is a program that lets you do absolutely nothing. Please report any problems or feature requests to the &kde; mailing lists. -Using &kmyapplication; +Using &rekonq; patent issues. --> -Here's a screenshot of &kmyapplication; +Here's a screenshot of &rekonq; @@ -168,7 +167,7 @@ patent issues. --> -More &kmyapplication; features +More &rekonq; features It slices! It dices! and it comes with a free toaster! @@ -183,7 +182,7 @@ The Squiggle Tool Squiggle is used to draw squiggly lines all over -the &kmyapplication; main window. It's not a bug, it's a feature! +the &rekonq; main window. It's not a bug, it's a feature! @@ -199,7 +198,7 @@ menus or toolbars. This may not be necessary for small apps or apps with no tool or menu bars. --> -The main &kmyapplication; window +The main &rekonq; window The File Menu @@ -233,7 +232,7 @@ or menu bars. --> File Quit -Quits &kmyapplication; +Quits &rekonq; @@ -244,7 +243,7 @@ or menu bars. --> The <guimenu>Help</guimenu> Menu - + @@ -256,14 +255,14 @@ or menu bars. --> -Developer's Guide to &kmyapplication; +Developer's Guide to &rekonq; -Programming &kmyapplication; plugins is a joy to behold. Just read through the next +Programming &rekonq; plugins is a joy to behold. Just read through the next 66 pages of API's to learn how! @@ -418,7 +417,7 @@ application work. --> -My Mouse doesn't work. How do I quit &kmyapplication;? +My Mouse doesn't work. How do I quit &rekonq;? You silly goose! Check out the Commands @@ -447,7 +446,7 @@ distribution. --> Credits and License -&kmyapplication; +&rekonq; Program copyright 2008 John Q. Hacker jqh@kde.org @@ -487,7 +486,7 @@ Documentation Copyright © 2008 George N. Ugnacious gnu@kde.orgInstallation -How to obtain &kmyapplication; +How to obtain &rekonq; -In order to successfully use &kmyapplication;, you need &kde; 1.1. Foobar.lib is -required in order to support the advanced &kmyapplication; features. &kmyapplication; uses +In order to successfully use &rekonq;, you need &kde; 1.1. Foobar.lib is +required in order to support the advanced &rekonq; features. &rekonq; uses about 5 megs of memory to run, but this may vary depending on your platform and configuration. -All required libraries as well as &kmyapplication; itself can be found -on The &kmyapplication; home page. +All required libraries as well as &rekonq; itself can be found +on The &rekonq; home page. - rekonq"> - - + + + Andrea + Diamantini + + "> + adjam7@gmail.com"> - - - + ]> - - - - - - - - - - - + The &rekonq; Handbook - - - -Andrea -Diamantini - -adjam7@gmail.com - +&Andrea.Diamantini; &Andrea.Diamantini.mail; - - 2008 -Andrea Diamantini +2009 +&Andrea.Diamantini; - - -&FDLNotice; - - -2008-12-01 -0.00.03 +&FDLNotice; - +2008-11-16 +0.0.3 -&rekonq; is an application specially designed to do nothing you would -ever want. +&rekonq; is a lightweight KDE browser based on WebKit. - - KDE -kdenetwork +browser rekonq webkit -browser - + -Introduction - +Introduction -&rekonq; is a program that lets you do absolutely nothing. Please report -any problems or feature requests to the &kde; mailing lists. +&rekonq; is a lightweight KDE browser based on WebKit. - - -Using &rekonq; + - +Launching &rekonq; +The Find Files tool is a useful method of searching for specific files on your +computer, or for searching for files that match a pattern. An example of +this could include searching for files of a particular type or with certain +letters in the filename. - - - -Here's a screenshot of &rekonq; - - - - - - - - - Screenshot - - - - - - - -More &rekonq; features - -It slices! It dices! and it comes with a free toaster! - -The Squiggle Tool - - - - - - - - Squiggle - - is used to draw squiggly lines all over -the &rekonq; main window. It's not a bug, it's a feature! +You can load this utility by clicking on Find Files. This will +launch &rekonq;. + - -Command Reference + - + +Finding Files - -The main &rekonq; window + +The Name/Location Tab - -The File Menu +When starting &rekonq;, you will see a quite simple window. Type in the +name of the file you are searching in the text box labeled +Named:. Choose a folder where you want to search +by typing it in the field Look in: +or by clicking Browse... and press +Enter or click Find. If +Include subfolders is checked all +subfolders starting from your chosen folder will be searched +too. The results will be displayed in the box below. + + + +You can use the following wildcards: + + - - -&Ctrl;N - -File -New - -Creates a new document - - - - -&Ctrl;S - -File -Save - -Saves the document +The Asterisk * + + +The asterisk stands for any number of missing characters (even zero), +that means ⪚ searching for marc* may find the +files marc, marc.png and + marc_must_not_read_this.kwd. +mar*.kwd may find +marketplace.kwd and +marc_must_not_read_this.kwd. + + + - - -&Ctrl;Q - -File -Quit - -Quits &rekonq; - - +The Question Mark ? + + +In contrast to the asterisk, the question mark stands for exactly one +character, so mar? will find +marc, but marc? will not find +anything, as our files are called marc and +marc.png. You can put as many question marks in the +term as you want, it will find exactly that number of characters. + + - - - -The <guimenu>Help</guimenu> Menu - - - - - - -&help.menu.documentation; + - + +Of course you can combine those two wildcard symbols in a search term. + - - - -Developer's Guide to &rekonq; - + +The Contents Tab + + +File type + -Programming &rekonq; plugins is a joy to behold. Just read through the next -66 pages of API's to learn how! +Here you can specify the type of file you are searching for. + + - - - - -XtUnmanageChildren -Xt - Geometry Management - - -XtUnmanageChildren - -remove a list of children from a parent widget's managed -list. -widgetsremoving -XtUnmanageChildren - - - - - -4 March 1996 - - -void XtUnmanageChildren(children, num_children) - WidgetList children; - Cardinal num_children; - - - -Inputs - -children - +Containing text -Specifies an array of child widgets. Each child must be of -class RectObj or any subclass thereof. + +Type in the word or phrase the files you are searching for must +contain. Note: If you do this in a large folder or checked +Include subfolders in the +Name/Location tab, this may take a long time. + + +This option will not work for all files listed +under File type. Only the following file types +are supported: + + +Text files, ⪚ source code and README files +&kword; >= 1.2 +&kpresenter; >= 1.2 +&kspread; >= 1.2 +OpenOffice.org Writer +OpenOffice.org Impress +OpenOffice.org Calc + + + + + + -num_children - +Case sensitive -Specifies the number of elements in children. + +If you enable this option, &rekonq; will +only find files with the exact case matching, ⪚ +MARC will only match +MARC, not Marc. + + +Regular expression +If you have installed the &kregexpeditor; tool from +the kdeutils package, you will have this additional option. Enabling +it will allow you to search for a regexp or +regular expression. A regexp is a way to specify conditions for your +search, and they can be very complex, and equally they can be very +powerful. If you are unfamiliar with regular expressions, you can +choose Edit Regular Expression to open +&kregexpeditor;. This tool allows you to construct your set of +conditions graphically, and then generates the expression for +you. + +&kregexpeditor; is a very useful tool, and can be used from within +many &kde; applications other than &rekonq;. You can find more +information from within its own help file. + + + + + - - - -Description - -XtUnmanageChildren() unmaps the specified widgets -and removes them from their parent's geometry management. -The widgets will disappear from the screen, and (depending -on its parent) may no longer have screen space allocated for -them. - -Each of the widgets in the children array must have -the same parent. - -See the “Algorithm” section below for full details of the -widget unmanagement procedure. - - - -Usage -Unmanaging widgets is the usual method for temporarily -making them invisible. They can be re-managed with -XtManageChildren(). - -You can unmap a widget, but leave it under geometry -management by calling XtUnmapWidget(). You can -destroy a widget's window without destroying the widget by -calling XtUnrealizeWidget(). You can destroy a -widget completely with XtDestroyWidget(). - -If you are only going to unmanage a single widget, it is -more convenient to call XtUnmanageChild(). It is -often more convenient to call XtUnmanageChild() -several times than it is to declare and initialize an array -of widgets to pass to XtUnmanageChildren(). Calling -XtUnmanageChildren() is more efficient, however, -because it only calls the parent's change_managed() -method once. - - + - -Algorithm - -XtUnmanageChildren() performs the following: + +The Properties Tab + + +Here you can refine your search. These are the special refinements +you can choose: + + -- - +Find all files created or modified -Ignores the child if it already is unmanaged or is being -destroyed. + +Here you can either enter two dates, between which the +files were created or modified, or specify a time period. + -- - +File size is -Otherwise, if the child is realized, it makes it nonvisible -by unmapping it. +Here you can specify if the file has to be at least or as most as +big as the size you entered in the following box. - - - - - -Structures -The WidgetList type is simply an array of widgets: + +Files owned by user, Files owned by group + +Here you can specify user and group names. -typedef Widget *WidgetList; - - - + + - + + + - -Questions and Answers - - - -&reporting.bugs; -&updating.documentation; - - - - -My Mouse doesn't work. How do I quit &rekonq;? - - -You silly goose! Check out the Commands -Section for the answer. - - - - -Why can't I twiddle my documents? - - -You can only twiddle your documents if you have the foobar.lib -installed. - - - - + - + Credits and License -&rekonq; +&rekonq; + -Program copyright 2008 John Q. Hacker jqh@kde.org +Program copyright: - -Contributors: + -Konqui the KDE Dragon konqui@kde.org - -Tux the Linux Penguin tux@linux.org +Developers + +&Andrea.Diamantini; &Andrea.Diamantini.mail; + - -Documentation Copyright © 2008 George N. Ugnacious gnu@kde.org - +Documentation copyright 2008 &Andrea.Diamantini; &Andrea.Diamantini.mail; + &underFDL; - - - -&underGPL; &underBSDLicense; -&underArtisticLicense; -&underX11License; Installation - + How to obtain &rekonq; - - &install.intro.documentation; @@ -499,70 +307,21 @@ application --> Requirements - - -In order to successfully use &rekonq;, you need &kde; 1.1. Foobar.lib is -required in order to support the advanced &rekonq; features. &rekonq; uses -about 5 megs of memory to run, but this may vary depending on your -platform and configuration. +In order to successfully use &rekonq;, you need at least Qt 4.4.x and &kde; 4.1.x. - -All required libraries as well as &rekonq; itself can be found -on The &rekonq; home page. - - - - -You can find a list of changes at http://apps.kde.org/kapp. - Compilation and Installation - - - - &install.compile.documentation; - -Configuration - -Don't forget to tell your system to start the dtd -dicer-toaster daemon first, or &rekonq; won't work ! - - - &documentation.index; - - + -- cgit v1.2.1 From ab64a769b0cd6fd392b26b5ab6520f31c28a30e0 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 01:14:05 +0100 Subject: Fixed notfound.html --- htmls/notfound.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htmls/notfound.html b/htmls/notfound.html index 77994119..6ffbc9f3 100644 --- a/htmls/notfound.html +++ b/htmls/notfound.html @@ -54,8 +54,10 @@ ul {
  • If the address is correct, try to check the network connection.
  • If your computer or network is protected by a firewall or - proxy, make sure that the browser demo is permitted to access + proxy, make sure that rekonq is permitted to access the network.
  • +
  • Of course, if rekonq doesn't work properly, you can always + say it's a programmer error ;)


  • -- cgit v1.2.1 From e095ed8b62c56745367fe79186431fe4f175d777 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 01:14:46 +0100 Subject: Fixed download problems rewamp proxy ui fixing settings --- src/download.cpp | 19 +++++++++---------- src/download.h | 4 ---- src/networkaccessmanager.cpp | 2 +- src/rekonq.kcfg | 2 +- src/settings.cpp | 11 +++++++++-- src/settings_proxy.ui | 41 ++++++++++++++++++++++++----------------- src/webview.cpp | 10 ++++++++++ 7 files changed, 54 insertions(+), 35 deletions(-) diff --git a/src/download.cpp b/src/download.cpp index aedd0a63..d1ed296a 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -33,7 +33,7 @@ Download::Download(const KUrl &srcUrl, const KUrl &destUrl) : m_srcUrl(srcUrl), m_destUrl(destUrl) { - kDebug(5001) << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); + kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); m_copyJob = KIO::get(m_srcUrl); connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); @@ -56,27 +56,26 @@ void Download::slotResult(KJob * job) { case 0://The download has finished { - kDebug(5001) << "Downloading successfully finished" << m_destUrl.url(); - QFile torrentFile(m_destUrl.path()); - if (!torrentFile.open(QIODevice::WriteOnly | QIODevice::Text)) {} - torrentFile.write(m_data); - torrentFile.close(); - emit finishedSuccessfully(m_destUrl, m_data); + kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); + QFile destFile(m_destUrl.path()); + if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) + { + destFile.write(m_data); + destFile.close(); + } m_data = 0; break; } case KIO::ERR_FILE_ALREADY_EXIST: { kDebug(5001) << "ERROR - File already exists"; - QFile file(m_destUrl.path()); - emit finishedSuccessfully(m_destUrl, file.readAll()); + // QFile file(m_destUrl.path()); m_data = 0; break; } default: kDebug(5001) << "We are sorry to say you, that there were errors while downloading :("; m_data = 0; - emit finishedWithError(); break; } } diff --git a/src/download.h b/src/download.h index 7986341d..65f36d3b 100644 --- a/src/download.h +++ b/src/download.h @@ -37,10 +37,6 @@ class Download : public QObject Download(const KUrl &srcUrl, const KUrl &destUrl); ~Download(); - Q_SIGNALS: - void finishedSuccessfully(KUrl dest, QByteArray data); - void finishedWithError(); - private slots: void slotResult(KJob * job); void slotData(KIO::Job *job, const QByteArray& data); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 1d601440..82947c3b 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -64,7 +64,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) void NetworkAccessManager::loadSettings() { QNetworkProxy proxy; - if ( ReKonfig::enableProxy() ) + if ( ReKonfig::isProxyEnabled() ) { if ( ReKonfig::proxyType() == 0 ) { diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index c20134be..a1b6ca4c 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -50,7 +50,7 @@ - + false diff --git a/src/settings.cpp b/src/settings.cpp index 462874f9..2181d0fd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -131,10 +131,17 @@ void SettingsDialog::readConfig() connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)),this, SLOT(saveSettings())); // ======= Fonts - d->fontsUi.standardFontChooser->setFont(ReKonfig::standardFont(), false); + QFont stdFont = ReKonfig::standardFont(); + d->fontsUi.standardFontChooser->setFont(stdFont, false); connect(d->fontsUi.standardFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); - d->fontsUi.fixedFontChooser->setFont(ReKonfig::fixedFont(), true); + QFont fxFont = ReKonfig::fixedFont(); + d->fontsUi.fixedFontChooser->setFont(fxFont, true); connect(d->fontsUi.fixedFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); + + // ======= Proxy + bool proxyEnabled = ReKonfig::isProxyEnabled(); + d->proxyUi.groupBox->setEnabled(proxyEnabled); + connect(d->proxyUi.kcfg_isProxyEnabled, SIGNAL(clicked(bool)), d->proxyUi.groupBox, SLOT(setEnabled(bool))); } diff --git a/src/settings_proxy.ui b/src/settings_proxy.ui index a7dd6073..bcee0a7e 100644 --- a/src/settings_proxy.ui +++ b/src/settings_proxy.ui @@ -5,21 +5,28 @@ 0 0 - 472 - 221 + 440 + 223 Proxy - + - + + + enable proxy + + + + + - Enable proxy + Proxy Settings - + Type: @@ -29,7 +36,7 @@ - + @@ -43,7 +50,7 @@ - + Host: @@ -53,10 +60,10 @@ - + - + Port: @@ -66,7 +73,7 @@ - + 10000 @@ -76,7 +83,7 @@ - + Qt::Horizontal @@ -89,7 +96,7 @@ - + User Name: @@ -99,10 +106,10 @@ - + - + Password: @@ -112,10 +119,10 @@ - + - + Qt::Vertical diff --git a/src/webview.cpp b/src/webview.cpp index a4ca8211..95fcdf83 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -126,6 +126,11 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { KUrl srcUrl = reply->url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); + QFile file(path); + if (file.exists()) + { + path = KFileDialog::getOpenFileName(); + } KUrl destUrl = KUrl(path); BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); return; @@ -312,6 +317,11 @@ void WebView::downloadRequested(const QNetworkRequest &request) { KUrl srcUrl = request.url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); + QFile file(path); + if (file.exists()) + { + path = KFileDialog::getOpenFileName(); + } KUrl destUrl = KUrl(path); BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); } -- cgit v1.2.1 From 641b34b0c2de8ccdf250bc8a8d95cfb0ea4a1f45 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 01:56:58 +0100 Subject: rekonq 0.0.3 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e53eef3c..5fc3d30e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ static const char description[] = I18N_NOOP("KDE Browser Webkit Based"); -static const char version[] = "0.0.2"; +static const char version[] = "0.0.3"; int main(int argc, char **argv) { -- cgit v1.2.1 From 3afb0217d09a012c4a65740155b232c67fef4990 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 01:57:19 +0100 Subject: Fixed download system about downloading files with the same name. --- src/download.cpp | 8 +++++++- src/webview.cpp | 10 ---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/download.cpp b/src/download.cpp index d1ed296a..e4ee556d 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -58,6 +58,13 @@ void Download::slotResult(KJob * job) { kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); QFile destFile(m_destUrl.path()); + int n = 1; + while( destFile.exists() ) + { + QString fn = QFile(m_destUrl.path()).fileName(); + destFile.setFileName( fn + "." + QString::number(n) ); + n++; + } if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) { destFile.write(m_data); @@ -69,7 +76,6 @@ void Download::slotResult(KJob * job) case KIO::ERR_FILE_ALREADY_EXIST: { kDebug(5001) << "ERROR - File already exists"; - // QFile file(m_destUrl.path()); m_data = 0; break; } diff --git a/src/webview.cpp b/src/webview.cpp index 95fcdf83..a4ca8211 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -126,11 +126,6 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) { KUrl srcUrl = reply->url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); - QFile file(path); - if (file.exists()) - { - path = KFileDialog::getOpenFileName(); - } KUrl destUrl = KUrl(path); BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); return; @@ -317,11 +312,6 @@ void WebView::downloadRequested(const QNetworkRequest &request) { KUrl srcUrl = request.url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); - QFile file(path); - if (file.exists()) - { - path = KFileDialog::getOpenFileName(); - } KUrl destUrl = KUrl(path); BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); } -- cgit v1.2.1 From 75abb0c0190b991b0766f56e4823666f9c7326c4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 09:34:13 +0100 Subject: Code Optimization --- src/download.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/download.cpp b/src/download.cpp index e4ee556d..627b11b2 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -51,7 +51,6 @@ void Download::slotData(KIO::Job *job, const QByteArray& data) void Download::slotResult(KJob * job) { - kDebug(5001); switch (job->error()) { case 0://The download has finished @@ -59,9 +58,9 @@ void Download::slotResult(KJob * job) kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); QFile destFile(m_destUrl.path()); int n = 1; + QString fn = destFile.fileName(); while( destFile.exists() ) { - QString fn = QFile(m_destUrl.path()).fileName(); destFile.setFileName( fn + "." + QString::number(n) ); n++; } @@ -75,12 +74,12 @@ void Download::slotResult(KJob * job) } case KIO::ERR_FILE_ALREADY_EXIST: { - kDebug(5001) << "ERROR - File already exists"; + kWarning() << "ERROR - File already exists"; m_data = 0; break; } default: - kDebug(5001) << "We are sorry to say you, that there were errors while downloading :("; + kWarning() << "We are sorry to say you, that there were errors while downloading :("; m_data = 0; break; } -- cgit v1.2.1 From 1dacbee9f2982947664559f3f7d998a89e768b73 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 09:50:23 +0100 Subject: Removed unuseful squeezelabel class --- src/CMakeLists.txt | 3 +-- src/squeezelabel.cpp | 39 --------------------------------------- src/squeezelabel.h | 39 --------------------------------------- 3 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 src/squeezelabel.cpp delete mode 100644 src/squeezelabel.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b18f6275..19355e7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,8 +15,7 @@ SET( rekonq_SRCS urlbar.cpp findbar.cpp searchbar.cpp - settings.cpp - squeezelabel.cpp + settings.cpp webview.cpp main.cpp ) diff --git a/src/squeezelabel.cpp b/src/squeezelabel.cpp deleted file mode 100644 index 7aa9e177..00000000 --- a/src/squeezelabel.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#include "squeezelabel.h" - -SqueezeLabel::SqueezeLabel(QWidget *parent) : QLabel(parent) -{ -} - -void SqueezeLabel::paintEvent(QPaintEvent *event) -{ - QFontMetrics fm = fontMetrics(); - if (fm.width(text()) > contentsRect().width()) { - QString elided = fm.elidedText(text(), Qt::ElideMiddle, width()); - QString oldText = text(); - setText(elided); - QLabel::paintEvent(event); - setText(oldText); - } else { - QLabel::paintEvent(event); - } -} diff --git a/src/squeezelabel.h b/src/squeezelabel.h deleted file mode 100644 index a7906270..00000000 --- a/src/squeezelabel.h +++ /dev/null @@ -1,39 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - -#ifndef SQUEEZELABEL_H -#define SQUEEZELABEL_H - -#include - -class SqueezeLabel : public QLabel -{ - Q_OBJECT - -public: - SqueezeLabel(QWidget *parent = 0); - -protected: - void paintEvent(QPaintEvent *event); - -}; - -#endif // SQUEEZELABEL_H - -- cgit v1.2.1 From a58e32712e675fd746317c3a72118d3351a4d3bb Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 2 Feb 2009 09:50:58 +0100 Subject: updated version info --- CMakeLists.txt | 2 +- rekonq.SlackBuild | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9ef464d..9578c73d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ PROJECT( rekonq ) # rekonq version SET(REKONQ_MAJOR_VERSION "0") SET(REKONQ_MINOR_VERSION "0") -SET(REKONQ_PATCH_VERSION "2") +SET(REKONQ_PATCH_VERSION "3") SET(REKONQ_VERSION_STRING "${REKONQ_MAJOR_VERSION}.${REKONQ_MINOR_VERSION}.${REKONQ_PATCH_VERSION}" diff --git a/rekonq.SlackBuild b/rekonq.SlackBuild index eefdc684..000314ee 100644 --- a/rekonq.SlackBuild +++ b/rekonq.SlackBuild @@ -4,7 +4,7 @@ # Written by Andrea Diamantini - adjam7_AT_gmail_DOT_com NAME=rekonq -VERSION=0.0.2 +VERSION=0.0.3 ARCH=${ARCH:-i486} BUILD=1ad -- cgit v1.2.1 From 0ee5dac23e4b687755c18dd68bcc47625bc59532 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 8 Feb 2009 18:53:48 +0100 Subject: Ready for 0.0.3 release. Last fixes.. --- CMakeLists.txt | 2 +- src/mainwindow.cpp | 7 +++++-- src/rekonqui.rc | 6 +++--- src/settings.cpp | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9578c73d..56d8f9b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,7 +84,7 @@ IF(REKONQ_CAN_BE_COMPILED) ADD_SUBDIRECTORY( icons ) ADD_SUBDIRECTORY( data ) ADD_SUBDIRECTORY( htmls ) - ADD_SUBDIRECTORY( doc ) +# ADD_SUBDIRECTORY( doc ) ENDIF(REKONQ_CAN_BE_COMPILED) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 294bf589..ecd5e452 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -73,8 +73,7 @@ MainWindow::MainWindow() // updating rekonq configuration slotUpdateConf(); -// QTimer::singleShot(0, this, SLOT( postLaunch() ) ); - + // creating a new tab m_view->newTab(); @@ -137,6 +136,10 @@ MainWindow::MainWindow() KToolBar *bmToolbar = toolBar("bookmarksToolBar"); m_bookmarksProvider->provideBmToolbar( bmToolbar ); + // setting up toolbars to NOT have context menu enabled + setContextMenuPolicy( Qt::ActionsContextMenu ); + + // search bar m_searchBar = new SearchBar( this ); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); navigationBar->addWidget(m_searchBar); diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 861f8538..0e372e82 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,5 +1,5 @@ - + &File @@ -59,7 +59,7 @@ -Main Toolbar +Main Toolbar @@ -67,7 +67,7 @@ -Bookmarks Toolbar + diff --git a/src/settings.cpp b/src/settings.cpp index 2181d0fd..7ab6e3dc 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -133,9 +133,11 @@ void SettingsDialog::readConfig() // ======= Fonts QFont stdFont = ReKonfig::standardFont(); d->fontsUi.standardFontChooser->setFont(stdFont, false); + d->fontsUi.standardFontChooser->setSampleText( stdFont.family() + " " + QString::number(stdFont.pointSize()) ); connect(d->fontsUi.standardFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); QFont fxFont = ReKonfig::fixedFont(); d->fontsUi.fixedFontChooser->setFont(fxFont, true); + d->fontsUi.fixedFontChooser->setSampleText( fxFont.family() + " " + QString::number(fxFont.pointSize()) ); connect(d->fontsUi.fixedFontChooser, SIGNAL(fontSelected(QFont)),this, SLOT(saveSettings())); // ======= Proxy -- cgit v1.2.1 From c41a1e2fce817725adfa4e6c45073103965f52c4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 8 Feb 2009 18:57:45 +0100 Subject: Updating --- ChangeLog | 6 +++--- TODO | 46 ++++++---------------------------------------- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49e7930f..473a1d76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,10 @@ 0.0.3 - ~80% ported to KDE4 -- KConfigXT support +- use KConfigXT - improved text search bar - fixed all "web actions" -- adopted KDE download system -- new bookmark toolbar +- KDE download system +- new bookmark toolbar (1st implementation) 0.0.2 - 70% ported to KDE4 diff --git a/TODO b/TODO index 2726e1b7..ce205bcd 100644 --- a/TODO +++ b/TODO @@ -1,49 +1,15 @@ -Road to 0.0.1 (first release) -+ ESC event findbar -+ let findbar work -+ bookmarks (share konqueror's) -+ some porting - -ROAD to 0.0.2 (second release) -+ setting rekonq with KConfigDialog ("rekonfig") -- configure shortcuts -- better find toolbar -- fixed search bar width - -ROAD to 0.0.3 (third release) -+ mainview -+ KConfigXT -+ downloadSystem-- -- documentation++ +To 0.0.4 +- improve DOCUMENTATION +- fix docs - autosave-- - dbus support - new application class!! - -+ REMOVE ALL FOCUS TO QStackedWidget in mainview!! -+ improve searchbar features -+ bookmarks line ---- fix sessions && ui dimension ---- fix KConfigXT use (proxy, fonts and so on..) - -+ ---------------------------------------------------- - -NEXT.. -+ system SELECT ALL -- better FULL SCREEN -- color progress +- improve bookmarks toolbar +- fix KConfigXT (fonts) +- color url_line_edit progress - contextMenu in searchbar to set different search engines - KDE proxy support -- KcookieJar - - QWebPluginFactory subclass to load KParts into QtWebKit. - -- dbus support - - kget support - - kwallet support - - kwrite support ( optional, to view HTML code ) - -- Kpart ?? - + ------------------------ -- cgit v1.2.1 From 8213829a830cabc2d9b44a43bba00f1dae77adc5 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 14 Feb 2009 12:06:54 +0100 Subject: Preliminary flash support --- src/CMakeLists.txt | 1 + src/webview.cpp | 13 ++++++++++++- src/webview.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 19355e7b..6fa9bd1c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,6 +44,7 @@ TARGET_LINK_LIBRARIES( rekonq ${QT_LIBRARIES} ${QT_QTNETWORK_LIBRARY} ${QT_QTWEBKIT_LIBRARY} + ${QT_QTUITOOLS_LIBRARY} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ) diff --git a/src/webview.cpp b/src/webview.cpp index a4ca8211..5d317597 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -42,7 +42,8 @@ #include #include #include - +// --- +#include WebPage::WebPage(QObject *parent) : QWebPage(parent) @@ -120,6 +121,16 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) } +QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +{ + Q_UNUSED(url); + Q_UNUSED(paramNames); + Q_UNUSED(paramValues); + QUiLoader loader; + return loader.createWidget(classId, view()); +} + + void WebPage::handleUnsupportedContent(QNetworkReply *reply) { if (reply->error() == QNetworkReply::NoError) diff --git a/src/webview.h b/src/webview.h index 6710aac4..6892fbd4 100644 --- a/src/webview.h +++ b/src/webview.h @@ -50,6 +50,7 @@ public: protected: bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); QWebPage *createWindow(QWebPage::WebWindowType type); + QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); private slots: void handleUnsupportedContent(QNetworkReply *reply); -- cgit v1.2.1 From 0edb6762d04a9ba1cf3196668597b8cbe3703ce2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 15 Feb 2009 15:27:40 +0100 Subject: Renamed Application class files --- src/application.cpp | 338 +++++++++++++++++++++++++++++++++++++++++++++ src/application.h | 90 ++++++++++++ src/browserapplication.cpp | 338 --------------------------------------------- src/browserapplication.h | 90 ------------ 4 files changed, 428 insertions(+), 428 deletions(-) create mode 100644 src/application.cpp create mode 100644 src/application.h delete mode 100644 src/browserapplication.cpp delete mode 100644 src/browserapplication.h diff --git a/src/application.cpp b/src/application.cpp new file mode 100644 index 00000000..a82b095c --- /dev/null +++ b/src/application.cpp @@ -0,0 +1,338 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +// Local Includes +#include "browserapplication.h" + +#include "rekonq.h" + +#include "mainwindow.h" +#include "cookiejar.h" +#include "history.h" +#include "networkaccessmanager.h" +#include "mainview.h" +#include "webview.h" +#include "download.h" + +// KDE Includes +#include +#include +#include +#include +#include + +// Qt Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +HistoryManager *BrowserApplication::s_historyManager = 0; +NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0; + + + +BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &serverName) + : KApplication() + , m_localServer(0) +{ + QLocalSocket socket; + socket.connectToServer(serverName); + if (socket.waitForConnected(500)) + { + QTextStream stream(&socket); + int n = args->count(); + if (n > 1) + stream << args->arg(n-1); + else + stream << QString(); + stream.flush(); + socket.waitForBytesWritten(); + return; + } + + KApplication::setQuitOnLastWindowClosed(true); + + m_localServer = new QLocalServer(this); + connect(m_localServer, SIGNAL(newConnection()), this, SLOT(newLocalSocketConnection())); + if (!m_localServer->listen(serverName)) + { + if (m_localServer->serverError() == QAbstractSocket::AddressInUseError + && QFile::exists(m_localServer->serverName())) + { + QFile::remove(m_localServer->serverName()); + m_localServer->listen(serverName); + } + } + + QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); + QString localSysName = QLocale::system().name(); + + KConfig config("rekonqrc"); + KConfigGroup group = config.group("sessions"); + m_lastSession = group.readEntry( QString("lastSession"), QByteArray() ); + + setWindowIcon( KIcon("rekonq") ); + + QTimer::singleShot(0, this, SLOT( postLaunch() ) ); +} + + +BrowserApplication::~BrowserApplication() +{ + qDeleteAll(m_mainWindows); + delete s_networkAccessManager; +} + + +BrowserApplication *BrowserApplication::instance() +{ + return (static_cast(QCoreApplication::instance())); +} + + +/*! + Any actions that can be delayed until the window is visible + */ +void BrowserApplication::postLaunch() +{ + QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + if ( directory.isEmpty() ) + { + directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); + } + QWebSettings::setIconDatabasePath(directory); + + // newMainWindow() needs to be called in main() for this to happen + if (m_mainWindows.count() > 0) + { + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + int n = args->count(); + if (n > 1) + { + KUrl url = MainWindow::guessUrlFromString( args->arg(n-1) ); + mainWindow()->loadUrl( url ); + } + else + { + mainWindow()->slotHome(); + } + } + BrowserApplication::historyManager(); +} + + +void BrowserApplication::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) +{ + new Download( srcUrl, destUrl ); +} + + +QList BrowserApplication::mainWindows() +{ + clean(); + QList list; + for (int i = 0; i < m_mainWindows.count(); ++i) + { + list.append(m_mainWindows.at(i)); + } + return list; +} + + +void BrowserApplication::clean() +{ + // cleanup any deleted main windows first + for (int i = m_mainWindows.count() - 1; i >= 0; --i) + { + if (m_mainWindows.at(i).isNull()) + { + m_mainWindows.removeAt(i); + } + } +} + + +void BrowserApplication::saveSession() +{ + QWebSettings *globalSettings = QWebSettings::globalSettings(); + if ( globalSettings->testAttribute( QWebSettings::PrivateBrowsingEnabled ) ) + return; + + clean(); + + KConfig config("rekonqrc"); + KConfigGroup group = config.group("sessions"); + QByteArray data; + QBuffer buffer(&data); + QDataStream stream(&buffer); + buffer.open(QIODevice::ReadWrite); + + stream << m_mainWindows.count(); + for (int i = 0; i < m_mainWindows.count(); ++i) + { + stream << m_mainWindows.at(i)->saveState(); + } + + group.writeEntry( QString("lastSession"), data ); +} + + +bool BrowserApplication::canRestoreSession() const +{ + return !m_lastSession.isEmpty(); +} + + +void BrowserApplication::restoreLastSession() +{ + QList windows; + QBuffer buffer(&m_lastSession); + QDataStream stream(&buffer); + buffer.open(QIODevice::ReadOnly); + int windowCount; + stream >> windowCount; + for (int i = 0; i < windowCount; ++i) + { + QByteArray windowState; + stream >> windowState; + windows.append(windowState); + } + for (int i = 0; i < windows.count(); ++i) + { + MainWindow *newWindow = 0; + if (m_mainWindows.count() == 1 + && mainWindow()->tabWidget()->count() == 1 + && mainWindow()->currentTab()->url() == KUrl()) + { + newWindow = mainWindow(); + } + else + { + newWindow = newMainWindow(); + } + newWindow->restoreState(windows.at(i)); + } +} + + + +bool BrowserApplication::isTheOnlyBrowser() const +{ + return (m_localServer != 0); +} + + +void BrowserApplication::openUrl(const KUrl &url) +{ + mainWindow()->loadUrl(url); +} + + + +MainWindow *BrowserApplication::newMainWindow() +{ + MainWindow *browser = new MainWindow(); + m_mainWindows.prepend(browser); + browser->show(); + return browser; +} + + +MainWindow *BrowserApplication::mainWindow() +{ + clean(); + if (m_mainWindows.isEmpty()) + newMainWindow(); + return m_mainWindows[0]; +} + + +void BrowserApplication::newLocalSocketConnection() +{ + QLocalSocket *socket = m_localServer->nextPendingConnection(); + if (!socket) + return; + socket->waitForReadyRead(1000); + QTextStream stream(socket); + QString url; + stream >> url; + if (!url.isEmpty()) + { + mainWindow()->tabWidget()->newTab(); + openUrl(url); + } + delete socket; + mainWindow()->raise(); + mainWindow()->activateWindow(); +} + + + +CookieJar *BrowserApplication::cookieJar() +{ + return (CookieJar*)networkAccessManager()->cookieJar(); +} + + +NetworkAccessManager *BrowserApplication::networkAccessManager() +{ + if (!s_networkAccessManager) + { + s_networkAccessManager = new NetworkAccessManager(); + s_networkAccessManager->setCookieJar(new CookieJar); + } + return s_networkAccessManager; +} + + + +HistoryManager *BrowserApplication::historyManager() +{ + if (!s_historyManager) + { + s_historyManager = new HistoryManager(); + QWebHistoryInterface::setDefaultInterface(s_historyManager); + } + return s_historyManager; +} + + + + +KIcon BrowserApplication::icon(const KUrl &url) const +{ + KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); + if (!icon.isNull()) + return icon; + if (m_defaultIcon.isNull()) + m_defaultIcon = KIcon("kde"); + return m_defaultIcon; +} + diff --git a/src/application.h b/src/application.h new file mode 100644 index 00000000..9b47bfcc --- /dev/null +++ b/src/application.h @@ -0,0 +1,90 @@ +/* ============================================================ + * + * This file is a part of the rekonq project + * + * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved + * Copyright (C) 2008 by Andrea Diamantini + * + * + * This program is free software; you can redistribute it + * and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; + * either version 2, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + * + * ============================================================ */ + + +#ifndef BROWSERAPPLICATION_H +#define BROWSERAPPLICATION_H + +// KDE Includes +#include +#include +#include +#include +#include +#include +#include + +// Qt Includes +#include + +QT_BEGIN_NAMESPACE +class QLocalServer; +QT_END_NAMESPACE + +class MainWindow; +class CookieJar; +class HistoryManager; +class NetworkAccessManager; + +class BrowserApplication : public KApplication +{ + Q_OBJECT + +public: + BrowserApplication(KCmdLineArgs*, const QString &); + ~BrowserApplication(); + static BrowserApplication *instance(); + + bool isTheOnlyBrowser() const; + MainWindow *mainWindow(); + QList mainWindows(); + KIcon icon(const KUrl &url) const; + void downloadUrl(const KUrl &srcUrl, const KUrl &destUrl); + + void saveSession(); + bool canRestoreSession() const; + + static HistoryManager *historyManager(); + static CookieJar *cookieJar(); + static NetworkAccessManager *networkAccessManager(); + +public slots: + MainWindow *newMainWindow(); + void restoreLastSession(); + +private slots: + void postLaunch(); + void openUrl(const KUrl &url); + void newLocalSocketConnection(); + +private: + void clean(); + + static HistoryManager *s_historyManager; + static NetworkAccessManager *s_networkAccessManager; + + QList > m_mainWindows; + QLocalServer *m_localServer; + QByteArray m_lastSession; + mutable KIcon m_defaultIcon; +}; + +#endif // BROWSERAPPLICATION_H + diff --git a/src/browserapplication.cpp b/src/browserapplication.cpp deleted file mode 100644 index a82b095c..00000000 --- a/src/browserapplication.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -// Local Includes -#include "browserapplication.h" - -#include "rekonq.h" - -#include "mainwindow.h" -#include "cookiejar.h" -#include "history.h" -#include "networkaccessmanager.h" -#include "mainview.h" -#include "webview.h" -#include "download.h" - -// KDE Includes -#include -#include -#include -#include -#include - -// Qt Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - - -HistoryManager *BrowserApplication::s_historyManager = 0; -NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0; - - - -BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &serverName) - : KApplication() - , m_localServer(0) -{ - QLocalSocket socket; - socket.connectToServer(serverName); - if (socket.waitForConnected(500)) - { - QTextStream stream(&socket); - int n = args->count(); - if (n > 1) - stream << args->arg(n-1); - else - stream << QString(); - stream.flush(); - socket.waitForBytesWritten(); - return; - } - - KApplication::setQuitOnLastWindowClosed(true); - - m_localServer = new QLocalServer(this); - connect(m_localServer, SIGNAL(newConnection()), this, SLOT(newLocalSocketConnection())); - if (!m_localServer->listen(serverName)) - { - if (m_localServer->serverError() == QAbstractSocket::AddressInUseError - && QFile::exists(m_localServer->serverName())) - { - QFile::remove(m_localServer->serverName()); - m_localServer->listen(serverName); - } - } - - QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); - QString localSysName = QLocale::system().name(); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("sessions"); - m_lastSession = group.readEntry( QString("lastSession"), QByteArray() ); - - setWindowIcon( KIcon("rekonq") ); - - QTimer::singleShot(0, this, SLOT( postLaunch() ) ); -} - - -BrowserApplication::~BrowserApplication() -{ - qDeleteAll(m_mainWindows); - delete s_networkAccessManager; -} - - -BrowserApplication *BrowserApplication::instance() -{ - return (static_cast(QCoreApplication::instance())); -} - - -/*! - Any actions that can be delayed until the window is visible - */ -void BrowserApplication::postLaunch() -{ - QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - if ( directory.isEmpty() ) - { - directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); - } - QWebSettings::setIconDatabasePath(directory); - - // newMainWindow() needs to be called in main() for this to happen - if (m_mainWindows.count() > 0) - { - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - int n = args->count(); - if (n > 1) - { - KUrl url = MainWindow::guessUrlFromString( args->arg(n-1) ); - mainWindow()->loadUrl( url ); - } - else - { - mainWindow()->slotHome(); - } - } - BrowserApplication::historyManager(); -} - - -void BrowserApplication::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) -{ - new Download( srcUrl, destUrl ); -} - - -QList BrowserApplication::mainWindows() -{ - clean(); - QList list; - for (int i = 0; i < m_mainWindows.count(); ++i) - { - list.append(m_mainWindows.at(i)); - } - return list; -} - - -void BrowserApplication::clean() -{ - // cleanup any deleted main windows first - for (int i = m_mainWindows.count() - 1; i >= 0; --i) - { - if (m_mainWindows.at(i).isNull()) - { - m_mainWindows.removeAt(i); - } - } -} - - -void BrowserApplication::saveSession() -{ - QWebSettings *globalSettings = QWebSettings::globalSettings(); - if ( globalSettings->testAttribute( QWebSettings::PrivateBrowsingEnabled ) ) - return; - - clean(); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("sessions"); - QByteArray data; - QBuffer buffer(&data); - QDataStream stream(&buffer); - buffer.open(QIODevice::ReadWrite); - - stream << m_mainWindows.count(); - for (int i = 0; i < m_mainWindows.count(); ++i) - { - stream << m_mainWindows.at(i)->saveState(); - } - - group.writeEntry( QString("lastSession"), data ); -} - - -bool BrowserApplication::canRestoreSession() const -{ - return !m_lastSession.isEmpty(); -} - - -void BrowserApplication::restoreLastSession() -{ - QList windows; - QBuffer buffer(&m_lastSession); - QDataStream stream(&buffer); - buffer.open(QIODevice::ReadOnly); - int windowCount; - stream >> windowCount; - for (int i = 0; i < windowCount; ++i) - { - QByteArray windowState; - stream >> windowState; - windows.append(windowState); - } - for (int i = 0; i < windows.count(); ++i) - { - MainWindow *newWindow = 0; - if (m_mainWindows.count() == 1 - && mainWindow()->tabWidget()->count() == 1 - && mainWindow()->currentTab()->url() == KUrl()) - { - newWindow = mainWindow(); - } - else - { - newWindow = newMainWindow(); - } - newWindow->restoreState(windows.at(i)); - } -} - - - -bool BrowserApplication::isTheOnlyBrowser() const -{ - return (m_localServer != 0); -} - - -void BrowserApplication::openUrl(const KUrl &url) -{ - mainWindow()->loadUrl(url); -} - - - -MainWindow *BrowserApplication::newMainWindow() -{ - MainWindow *browser = new MainWindow(); - m_mainWindows.prepend(browser); - browser->show(); - return browser; -} - - -MainWindow *BrowserApplication::mainWindow() -{ - clean(); - if (m_mainWindows.isEmpty()) - newMainWindow(); - return m_mainWindows[0]; -} - - -void BrowserApplication::newLocalSocketConnection() -{ - QLocalSocket *socket = m_localServer->nextPendingConnection(); - if (!socket) - return; - socket->waitForReadyRead(1000); - QTextStream stream(socket); - QString url; - stream >> url; - if (!url.isEmpty()) - { - mainWindow()->tabWidget()->newTab(); - openUrl(url); - } - delete socket; - mainWindow()->raise(); - mainWindow()->activateWindow(); -} - - - -CookieJar *BrowserApplication::cookieJar() -{ - return (CookieJar*)networkAccessManager()->cookieJar(); -} - - -NetworkAccessManager *BrowserApplication::networkAccessManager() -{ - if (!s_networkAccessManager) - { - s_networkAccessManager = new NetworkAccessManager(); - s_networkAccessManager->setCookieJar(new CookieJar); - } - return s_networkAccessManager; -} - - - -HistoryManager *BrowserApplication::historyManager() -{ - if (!s_historyManager) - { - s_historyManager = new HistoryManager(); - QWebHistoryInterface::setDefaultInterface(s_historyManager); - } - return s_historyManager; -} - - - - -KIcon BrowserApplication::icon(const KUrl &url) const -{ - KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); - if (!icon.isNull()) - return icon; - if (m_defaultIcon.isNull()) - m_defaultIcon = KIcon("kde"); - return m_defaultIcon; -} - diff --git a/src/browserapplication.h b/src/browserapplication.h deleted file mode 100644 index 9b47bfcc..00000000 --- a/src/browserapplication.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ============================================================ - * - * This file is a part of the rekonq project - * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved - * Copyright (C) 2008 by Andrea Diamantini - * - * - * This program is free software; you can redistribute it - * and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; - * either version 2, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * ============================================================ */ - - -#ifndef BROWSERAPPLICATION_H -#define BROWSERAPPLICATION_H - -// KDE Includes -#include -#include -#include -#include -#include -#include -#include - -// Qt Includes -#include - -QT_BEGIN_NAMESPACE -class QLocalServer; -QT_END_NAMESPACE - -class MainWindow; -class CookieJar; -class HistoryManager; -class NetworkAccessManager; - -class BrowserApplication : public KApplication -{ - Q_OBJECT - -public: - BrowserApplication(KCmdLineArgs*, const QString &); - ~BrowserApplication(); - static BrowserApplication *instance(); - - bool isTheOnlyBrowser() const; - MainWindow *mainWindow(); - QList mainWindows(); - KIcon icon(const KUrl &url) const; - void downloadUrl(const KUrl &srcUrl, const KUrl &destUrl); - - void saveSession(); - bool canRestoreSession() const; - - static HistoryManager *historyManager(); - static CookieJar *cookieJar(); - static NetworkAccessManager *networkAccessManager(); - -public slots: - MainWindow *newMainWindow(); - void restoreLastSession(); - -private slots: - void postLaunch(); - void openUrl(const KUrl &url); - void newLocalSocketConnection(); - -private: - void clean(); - - static HistoryManager *s_historyManager; - static NetworkAccessManager *s_networkAccessManager; - - QList > m_mainWindows; - QLocalServer *m_localServer; - QByteArray m_lastSession; - mutable KIcon m_defaultIcon; -}; - -#endif // BROWSERAPPLICATION_H - -- cgit v1.2.1 From f7792e37654fb9d0509171d946d53e7697ad53e8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 15 Feb 2009 15:35:47 +0100 Subject: BrowserApplication --> Application --- src/CMakeLists.txt | 2 +- src/application.cpp | 49 ++++++++++++++++++++++++------------------------- src/application.h | 15 +++++++-------- src/history.cpp | 8 ++++---- src/main.cpp | 4 ++-- 5 files changed, 38 insertions(+), 40 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b18f6275..6a7c5c2d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ SET( rekonq_SRCS autosaver.cpp - browserapplication.cpp + application.cpp mainwindow.cpp mainview.cpp tabbar.cpp diff --git a/src/application.cpp b/src/application.cpp index a82b095c..40addcac 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -2,7 +2,6 @@  *  * This file is a part of the rekonq project  * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * @@ -20,7 +19,7 @@ // Local Includes -#include "browserapplication.h" +#include "application.h" #include "rekonq.h" @@ -53,12 +52,12 @@ -HistoryManager *BrowserApplication::s_historyManager = 0; -NetworkAccessManager *BrowserApplication::s_networkAccessManager = 0; +HistoryManager *Application::s_historyManager = 0; +NetworkAccessManager *Application::s_networkAccessManager = 0; -BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &serverName) +Application::Application(KCmdLineArgs *args, const QString &serverName) : KApplication() , m_localServer(0) { @@ -104,23 +103,23 @@ BrowserApplication::BrowserApplication(KCmdLineArgs *args, const QString &server } -BrowserApplication::~BrowserApplication() +Application::~Application() { qDeleteAll(m_mainWindows); delete s_networkAccessManager; } -BrowserApplication *BrowserApplication::instance() +Application *Application::instance() { - return (static_cast(QCoreApplication::instance())); + return (static_cast(QCoreApplication::instance())); } /*! Any actions that can be delayed until the window is visible */ -void BrowserApplication::postLaunch() +void Application::postLaunch() { QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); if ( directory.isEmpty() ) @@ -144,17 +143,17 @@ void BrowserApplication::postLaunch() mainWindow()->slotHome(); } } - BrowserApplication::historyManager(); + Application::historyManager(); } -void BrowserApplication::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) +void Application::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) { new Download( srcUrl, destUrl ); } -QList BrowserApplication::mainWindows() +QList Application::mainWindows() { clean(); QList list; @@ -166,7 +165,7 @@ QList BrowserApplication::mainWindows() } -void BrowserApplication::clean() +void Application::clean() { // cleanup any deleted main windows first for (int i = m_mainWindows.count() - 1; i >= 0; --i) @@ -179,7 +178,7 @@ void BrowserApplication::clean() } -void BrowserApplication::saveSession() +void Application::saveSession() { QWebSettings *globalSettings = QWebSettings::globalSettings(); if ( globalSettings->testAttribute( QWebSettings::PrivateBrowsingEnabled ) ) @@ -204,13 +203,13 @@ void BrowserApplication::saveSession() } -bool BrowserApplication::canRestoreSession() const +bool Application::canRestoreSession() const { return !m_lastSession.isEmpty(); } -void BrowserApplication::restoreLastSession() +void Application::restoreLastSession() { QList windows; QBuffer buffer(&m_lastSession); @@ -243,20 +242,20 @@ void BrowserApplication::restoreLastSession() -bool BrowserApplication::isTheOnlyBrowser() const +bool Application::isTheOnlyBrowser() const { return (m_localServer != 0); } -void BrowserApplication::openUrl(const KUrl &url) +void Application::openUrl(const KUrl &url) { mainWindow()->loadUrl(url); } -MainWindow *BrowserApplication::newMainWindow() +MainWindow *Application::newMainWindow() { MainWindow *browser = new MainWindow(); m_mainWindows.prepend(browser); @@ -265,7 +264,7 @@ MainWindow *BrowserApplication::newMainWindow() } -MainWindow *BrowserApplication::mainWindow() +MainWindow *Application::mainWindow() { clean(); if (m_mainWindows.isEmpty()) @@ -274,7 +273,7 @@ MainWindow *BrowserApplication::mainWindow() } -void BrowserApplication::newLocalSocketConnection() +void Application::newLocalSocketConnection() { QLocalSocket *socket = m_localServer->nextPendingConnection(); if (!socket) @@ -295,13 +294,13 @@ void BrowserApplication::newLocalSocketConnection() -CookieJar *BrowserApplication::cookieJar() +CookieJar *Application::cookieJar() { return (CookieJar*)networkAccessManager()->cookieJar(); } -NetworkAccessManager *BrowserApplication::networkAccessManager() +NetworkAccessManager *Application::networkAccessManager() { if (!s_networkAccessManager) { @@ -313,7 +312,7 @@ NetworkAccessManager *BrowserApplication::networkAccessManager() -HistoryManager *BrowserApplication::historyManager() +HistoryManager *Application::historyManager() { if (!s_historyManager) { @@ -326,7 +325,7 @@ HistoryManager *BrowserApplication::historyManager() -KIcon BrowserApplication::icon(const KUrl &url) const +KIcon Application::icon(const KUrl &url) const { KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); if (!icon.isNull()) diff --git a/src/application.h b/src/application.h index 9b47bfcc..05fc008e 100644 --- a/src/application.h +++ b/src/application.h @@ -2,7 +2,6 @@  *  * This file is a part of the rekonq project  * - * Copyright (C) 2007-2008 Trolltech ASA. All rights reserved * Copyright (C) 2008 by Andrea Diamantini  * * @@ -19,8 +18,8 @@  * ============================================================ */ -#ifndef BROWSERAPPLICATION_H -#define BROWSERAPPLICATION_H +#ifndef REKONQ_APPLICATION_H +#define REKONQ_APPLICATION_H // KDE Includes #include @@ -43,14 +42,14 @@ class CookieJar; class HistoryManager; class NetworkAccessManager; -class BrowserApplication : public KApplication +class Application : public KApplication { Q_OBJECT public: - BrowserApplication(KCmdLineArgs*, const QString &); - ~BrowserApplication(); - static BrowserApplication *instance(); + Application(KCmdLineArgs*, const QString &); + ~Application(); + static Application *instance(); bool isTheOnlyBrowser() const; MainWindow *mainWindow(); @@ -86,5 +85,5 @@ private: mutable KIcon m_defaultIcon; }; -#endif // BROWSERAPPLICATION_H +#endif // REKONQ_APPLICATION_H diff --git a/src/history.cpp b/src/history.cpp index 652ee962..9813d438 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -27,7 +27,7 @@ // Local Includes #include "autosaver.h" -#include "browserapplication.h" +#include "application.h" // KDE Includes #include @@ -465,7 +465,7 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const } case Qt::DecorationRole: if (index.column() == 0) { - return BrowserApplication::instance()->icon(item.url); + return Application::instance()->icon(item.url); } } return QVariant(); @@ -643,7 +643,7 @@ bool HistoryMenu::prePopulated() { if (!m_history) { - m_history = BrowserApplication::historyManager(); + m_history = Application::historyManager(); m_historyMenuModel = new HistoryMenuModel(m_history->historyTreeModel(), this); setModel(m_historyMenuModel); } @@ -712,7 +712,7 @@ HistoryDialog::HistoryDialog(QWidget *parent, HistoryManager *setHistory) : QDia { HistoryManager *history = setHistory; if (!history) - history = BrowserApplication::historyManager(); + history = Application::historyManager(); setupUi(this); tree->setUniformRowHeights(true); tree->setSelectionBehavior(QAbstractItemView::SelectRows); diff --git a/src/main.cpp b/src/main.cpp index e53eef3c..c3ac0c00 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,7 +19,7 @@  * ============================================================ */ -#include "browserapplication.h" +#include "application.h" #include #include @@ -56,7 +56,7 @@ int main(int argc, char **argv) KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - BrowserApplication app(args, "rekonq"); + Application app(args, "rekonq"); if (!app.isTheOnlyBrowser()) return 0; app.newMainWindow(); -- cgit v1.2.1 From 39ff47469cdc4a7df148368ed60470dc042f677e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 15 Feb 2009 15:44:52 +0100 Subject: {Browser,}Application. Again.. --- src/mainview.cpp | 10 +++++----- src/mainwindow.cpp | 20 ++++++++++---------- src/networkaccessmanager.cpp | 8 ++++---- src/searchbar.cpp | 6 ++++-- src/settings.cpp | 6 +++--- src/tabbar.cpp | 2 +- src/urlbar.cpp | 4 ++-- src/webview.cpp | 18 +++++++++--------- 8 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index acef1998..a3030748 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -25,7 +25,7 @@ // Local Includes #include "tabbar.h" -#include "browserapplication.h" +#include "application.h" #include "mainwindow.h" #include "history.h" #include "urlbar.h" @@ -310,7 +310,7 @@ WebView *MainView::newTab(bool makeCurrent) if (!m_lineEditCompleter && count() > 0) { HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); - completionModel->setSourceModel(BrowserApplication::historyManager()->historyFilterModel()); + completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); m_lineEditCompleter = new QCompleter(completionModel, this); // Should this be in Qt by default? QAbstractItemView *popup = m_lineEditCompleter->popup(); @@ -492,7 +492,7 @@ void MainView::webViewIconChanged() int index = webViewIndex(webView); if (-1 != index) { - QIcon icon = BrowserApplication::instance()->icon(webView->url()); + QIcon icon = Application::instance()->icon(webView->url()); setTabIcon(index, icon); } } @@ -507,7 +507,7 @@ void MainView::webViewTitleChanged(const QString &title) } if (currentIndex() == index) emit setCurrentTitle(title); - BrowserApplication::historyManager()->updateHistoryItem(webView->url(), title); + Application::historyManager()->updateHistoryItem(webView->url(), title); } @@ -529,7 +529,7 @@ void MainView::aboutToShowRecentTabsMenu() { KAction *action = new KAction(m_recentlyClosedTabsMenu); action->setData(m_recentlyClosedTabs.at(i)); - QIcon icon = BrowserApplication::instance()->icon(m_recentlyClosedTabs.at(i)); + QIcon icon = Application::instance()->icon(m_recentlyClosedTabs.at(i)); action->setIcon(icon); action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); m_recentlyClosedTabsMenu->addAction(action); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ecd5e452..ee028abb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -27,7 +27,7 @@ #include "rekonq.h" // Local Includes -#include "browserapplication.h" +#include "application.h" #include "settings.h" #include "history.h" #include "cookiejar.h" @@ -319,9 +319,9 @@ void MainWindow::slotUpdateConf() defaultSettings->setAttribute(QWebSettings::JavascriptEnabled, isJavascriptEnabled); // load Settings on main classes - BrowserApplication::networkAccessManager()->loadSettings(); - BrowserApplication::cookieJar()->loadSettings(); - BrowserApplication::historyManager()->loadSettings(); + Application::networkAccessManager()->loadSettings(); + Application::cookieJar()->loadSettings(); + Application::historyManager()->loadSettings(); } @@ -402,7 +402,7 @@ void MainWindow::slotFileSaveAs() KUrl srcUrl = currentTab()->url(); QString destPath = KFileDialog::getSaveFileName(); KUrl destUrl = KUrl(destPath); - BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl( srcUrl, destUrl ); } @@ -444,8 +444,8 @@ void MainWindow::slotUpdateWindowTitle(const QString &title) void MainWindow::slotFileNew() { - BrowserApplication::instance()->newMainWindow(); - MainWindow *mw = BrowserApplication::instance()->mainWindow(); + Application::instance()->newMainWindow(); + MainWindow *mw = Application::instance()->mainWindow(); mw->slotHome(); } @@ -520,7 +520,7 @@ void MainWindow::slotPrivateBrowsing() { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); - QList windows = BrowserApplication::instance()->mainWindows(); + QList windows = Application::instance()->mainWindows(); for (int i = 0; i < windows.count(); ++i) { MainWindow *window = windows.at(i); @@ -718,7 +718,7 @@ void MainWindow::slotAboutToShowBackMenu() QWebHistoryItem item = history->backItems(history->count()).at(i); KAction *action = new KAction(this); action->setData(-1*(historyCount-i-1)); - QIcon icon = BrowserApplication::instance()->icon(item.url()); + QIcon icon = Application::instance()->icon(item.url()); action->setIcon(icon); action->setText(item.title()); m_historyBackMenu->addAction(action); @@ -734,7 +734,7 @@ void MainWindow::slotAboutToShowBackMenu() // if (v.canConvert()) // { // int offset = qvariant_cast(v); -// QList windows = BrowserApplication::instance()->mainWindows(); +// QList windows = Application::instance()->mainWindows(); // windows.at(offset)->activateWindow(); // windows.at(offset)->currentTab()->setFocus(); // } diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 82947c3b..f4e23fb1 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -23,7 +23,7 @@ #include "networkaccessmanager.moc" // Local Includes -#include "browserapplication.h" +#include "application.h" #include "mainwindow.h" // Auto Includes @@ -86,7 +86,7 @@ void NetworkAccessManager::loadSettings() void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) { - MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *mainWindow = Application::instance()->mainWindow(); QDialog dialog(mainWindow); dialog.setWindowFlags(Qt::Sheet); @@ -111,7 +111,7 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth) { - MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *mainWindow = Application::instance()->mainWindow(); QDialog dialog(mainWindow); dialog.setWindowFlags(Qt::Sheet); @@ -136,7 +136,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox #ifndef QT_NO_OPENSSL void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList &error) { - MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + MainWindow *mainWindow = Application::instance()->mainWindow(); QStringList errorStrings; for (int i = 0; i < error.count(); ++i) diff --git a/src/searchbar.cpp b/src/searchbar.cpp index c6889dba..2f03e93a 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -17,13 +17,15 @@  *  * ============================================================ */ -// Local Includes +// Self Includes #include "searchbar.h" #include "searchbar.moc" -#include "browserapplication.h" +// Local Includes +#include "application.h" #include "mainwindow.h" +// KDE Includes #include SearchBar::SearchBar(QWidget *parent) : diff --git a/src/settings.cpp b/src/settings.cpp index 7ab6e3dc..f5476ad3 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -27,7 +27,7 @@ #include "rekonq.h" // Local Includes -#include "browserapplication.h" +#include "application.h" #include "mainwindow.h" #include "cookiejar.h" #include "history.h" @@ -164,14 +164,14 @@ void SettingsDialog::saveSettings() void SettingsDialog::showCookies() { - CookiesDialog *dialog = new CookiesDialog(BrowserApplication::cookieJar(), this); + CookiesDialog *dialog = new CookiesDialog(Application::cookieJar(), this); dialog->exec(); } void SettingsDialog::showExceptions() { - CookiesExceptionsDialog *dialog = new CookiesExceptionsDialog(BrowserApplication::cookieJar(), this); + CookiesExceptionsDialog *dialog = new CookiesExceptionsDialog(Application::cookieJar(), this); dialog->exec(); } diff --git a/src/tabbar.cpp b/src/tabbar.cpp index bf63db03..c28a390c 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -23,7 +23,7 @@ #include "tabbar.moc" // Local Includes -#include "browserapplication.h" +#include "application.h" #include "mainwindow.h" #include "history.h" #include "urlbar.h" diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 5ddb26aa..3940d040 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -21,7 +21,7 @@ #include "urlbar.h" #include "urlbar.moc" -#include "browserapplication.h" +#include "application.h" #include "mainwindow.h" @@ -81,7 +81,7 @@ void UrlBar::webViewUrlChanged(const QUrl &url) void UrlBar::webViewIconChanged() { KUrl url = (m_webView) ? m_webView->url() : KUrl(); - QIcon icon = BrowserApplication::instance()->icon(url); + QIcon icon = Application::instance()->icon(url); QPixmap pixmap(icon.pixmap(16, 16)); QIcon urlIcon = QIcon(pixmap); diff --git a/src/webview.cpp b/src/webview.cpp index 5d317597..ab8ef5cd 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -26,7 +26,7 @@ #include "rekonq.h" // Local Includes -#include "browserapplication.h" +#include "application.h" #include "mainwindow.h" #include "mainview.h" #include "cookiejar.h" @@ -51,7 +51,7 @@ WebPage::WebPage(QObject *parent) , m_pressedButtons(Qt::NoButton) , m_openInNewTab(false) { - setNetworkAccessManager( BrowserApplication::networkAccessManager() ); + setNetworkAccessManager( Application::networkAccessManager() ); connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); } @@ -65,7 +65,7 @@ MainWindow *WebPage::mainWindow() return mw; w = w->parent(); } - return BrowserApplication::instance()->mainWindow(); + return Application::instance()->mainWindow(); } @@ -80,8 +80,8 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r WebView *webView; if (newWindow) { - BrowserApplication::instance()->newMainWindow(); - MainWindow *newMainWindow = BrowserApplication::instance()->mainWindow(); + Application::instance()->newMainWindow(); + MainWindow *newMainWindow = Application::instance()->mainWindow(); webView = newMainWindow->currentTab(); newMainWindow->raise(); newMainWindow->activateWindow(); @@ -115,8 +115,8 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) m_openInNewTab = false; return mainWindow()->tabWidget()->newTab()->page(); } - BrowserApplication::instance()->newMainWindow(); - MainWindow *mainWindow = BrowserApplication::instance()->mainWindow(); + Application::instance()->newMainWindow(); + MainWindow *mainWindow = Application::instance()->mainWindow(); return mainWindow->currentTab()->page(); } @@ -138,7 +138,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) KUrl srcUrl = reply->url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); KUrl destUrl = KUrl(path); - BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl( srcUrl, destUrl ); return; } @@ -324,7 +324,7 @@ void WebView::downloadRequested(const QNetworkRequest &request) KUrl srcUrl = request.url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); KUrl destUrl = KUrl(path); - BrowserApplication::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl( srcUrl, destUrl ); } -- cgit v1.2.1 From 43fa9af21ff14b895b1d0ef3b559b9236208eb79 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 15 Feb 2009 16:10:16 +0100 Subject: First bits of documentation.. --- src/application.h | 3 +++ src/bookmarks.h | 7 ++++++- src/download.h | 6 +++++- src/searchbar.h | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/application.h b/src/application.h index 05fc008e..32d810f0 100644 --- a/src/application.h +++ b/src/application.h @@ -42,6 +42,9 @@ class CookieJar; class HistoryManager; class NetworkAccessManager; +/* + * + */ class Application : public KApplication { Q_OBJECT diff --git a/src/bookmarks.h b/src/bookmarks.h index 2bdfab0a..aa18834c 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -24,7 +24,6 @@ #include #include #include - #include #include #include @@ -32,6 +31,9 @@ class MainWindow; +/* + * + */ class OwnBookMarks : public QObject , public KBookmarkOwner { Q_OBJECT @@ -53,6 +55,9 @@ private: // ------------------------------------------------------------------------------ +/* + * + */ class BookmarksProvider : public QObject { Q_OBJECT diff --git a/src/download.h b/src/download.h index 65f36d3b..cd363d00 100644 --- a/src/download.h +++ b/src/download.h @@ -29,7 +29,11 @@ #include #include - +/* + * This class lets rekonq to download an object from the network. + * Creating a new object, you can continue downloading a file also + * when rekonq is closed. + */ class Download : public QObject { Q_OBJECT diff --git a/src/searchbar.h b/src/searchbar.h index a83d7024..19c90a15 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -28,6 +28,9 @@ // Qt Includes #include +/* + * This class defines an internet search bar. + */ class SearchBar : public KLineEdit { Q_OBJECT @@ -37,6 +40,9 @@ public: ~SearchBar(); public slots: + /* + * Use this slot to perform one search in one search engine + */ void searchNow(); protected: -- cgit v1.2.1 From c905d3ebf987ee639a054229703281bb224ce054 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 15 Feb 2009 16:12:57 +0100 Subject: Modified adjam's mail --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 187011aa..c2e45199 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1 +1 @@ -Andrea Diamantini adjam7@gmail.com +Andrea Diamantini adjam7_AT_gmail_DOT_com -- cgit v1.2.1 From 4150695c5fff0504cf19ad74b3f185bd67397497 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 16 Feb 2009 00:06:28 +0100 Subject: new singleton Application class. Try 1.. --- data/rekonq.desktop | 2 +- src/application.cpp | 296 ++++++++++++++++++++-------------------------------- src/application.h | 42 ++++---- src/main.cpp | 16 +-- src/mainwindow.cpp | 34 +----- src/webview.cpp | 22 ++-- 6 files changed, 157 insertions(+), 255 deletions(-) diff --git a/data/rekonq.desktop b/data/rekonq.desktop index 5a93f099..a2aeca1b 100644 --- a/data/rekonq.desktop +++ b/data/rekonq.desktop @@ -7,4 +7,4 @@ Exec=rekonq %i DocPath=rekonq/index.html Categories=Qt;KDE;Network; Terminal=0 - +X-DBUS-StartupType=Unique diff --git a/src/application.cpp b/src/application.cpp index 40addcac..d6679b97 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -18,11 +18,14 @@  * ============================================================ */ -// Local Includes +// Self Includes #include "application.h" +#include "application.moc" +// Auto Includes #include "rekonq.h" +// Local Includes #include "mainwindow.h" #include "cookiejar.h" #include "history.h" @@ -56,46 +59,48 @@ HistoryManager *Application::s_historyManager = 0; NetworkAccessManager *Application::s_networkAccessManager = 0; - -Application::Application(KCmdLineArgs *args, const QString &serverName) - : KApplication() - , m_localServer(0) +Application::Application() + : KUniqueApplication() +// , m_localServer(0) { - QLocalSocket socket; - socket.connectToServer(serverName); - if (socket.waitForConnected(500)) - { - QTextStream stream(&socket); - int n = args->count(); - if (n > 1) - stream << args->arg(n-1); - else - stream << QString(); - stream.flush(); - socket.waitForBytesWritten(); - return; - } - - KApplication::setQuitOnLastWindowClosed(true); - - m_localServer = new QLocalServer(this); - connect(m_localServer, SIGNAL(newConnection()), this, SLOT(newLocalSocketConnection())); - if (!m_localServer->listen(serverName)) - { - if (m_localServer->serverError() == QAbstractSocket::AddressInUseError - && QFile::exists(m_localServer->serverName())) - { - QFile::remove(m_localServer->serverName()); - m_localServer->listen(serverName); - } - } - - QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); - QString localSysName = QLocale::system().name(); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("sessions"); - m_lastSession = group.readEntry( QString("lastSession"), QByteArray() ); + m_mainWindow = new MainWindow(); + m_mainWindow->show(); + +// QLocalSocket socket; +// socket.connectToServer(serverName); +// if (socket.waitForConnected(500)) +// { +// QTextStream stream(&socket); +// int n = args->count(); +// if (n > 1) +// stream << args->arg(n-1); +// else +// stream << QString(); +// stream.flush(); +// socket.waitForBytesWritten(); +// return; +// } +// +// KApplication::setQuitOnLastWindowClosed(true); +// +// m_localServer = new QLocalServer(this); +// connect(m_localServer, SIGNAL(newConnection()), this, SLOT(newLocalSocketConnection())); +// if (!m_localServer->listen(serverName)) +// { +// if (m_localServer->serverError() == QAbstractSocket::AddressInUseError +// && QFile::exists(m_localServer->serverName())) +// { +// QFile::remove(m_localServer->serverName()); +// m_localServer->listen(serverName); +// } +// } +// +// QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); +// QString localSysName = QLocale::system().name(); +// +// KConfig config("rekonqrc"); +// KConfigGroup group = config.group("sessions"); +// m_lastSession = group.readEntry( QString("lastSession"), QByteArray() ); setWindowIcon( KIcon("rekonq") ); @@ -105,147 +110,85 @@ Application::Application(KCmdLineArgs *args, const QString &serverName) Application::~Application() { - qDeleteAll(m_mainWindows); delete s_networkAccessManager; } -Application *Application::instance() -{ - return (static_cast(QCoreApplication::instance())); -} - - -/*! - Any actions that can be delayed until the window is visible - */ -void Application::postLaunch() +int Application::newInstance() { - QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); - if ( directory.isEmpty() ) - { - directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); - } - QWebSettings::setIconDatabasePath(directory); - - // newMainWindow() needs to be called in main() for this to happen - if (m_mainWindows.count() > 0) + KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); + static bool first = true; + if (args->count() > 0) { - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - int n = args->count(); - if (n > 1) + for (int i = 0; i < args->count(); ++i) { - KUrl url = MainWindow::guessUrlFromString( args->arg(n-1) ); + KUrl url = MainWindow::guessUrlFromString( args->arg(i) ); + newTab(); mainWindow()->loadUrl( url ); } - else + } + else + { + if( !first || !isSessionRestored()) { + newTab(); mainWindow()->slotHome(); } } - Application::historyManager(); -} - - -void Application::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) -{ - new Download( srcUrl, destUrl ); -} - - -QList Application::mainWindows() -{ - clean(); - QList list; - for (int i = 0; i < m_mainWindows.count(); ++i) - { - list.append(m_mainWindows.at(i)); - } - return list; + first = false; + args->clear(); + return 0; } -void Application::clean() +Application *Application::instance() { - // cleanup any deleted main windows first - for (int i = m_mainWindows.count() - 1; i >= 0; --i) - { - if (m_mainWindows.at(i).isNull()) - { - m_mainWindows.removeAt(i); - } - } + return (static_cast(QCoreApplication::instance())); } -void Application::saveSession() +void Application::postLaunch() { - QWebSettings *globalSettings = QWebSettings::globalSettings(); - if ( globalSettings->testAttribute( QWebSettings::PrivateBrowsingEnabled ) ) - return; - - clean(); - - KConfig config("rekonqrc"); - KConfigGroup group = config.group("sessions"); - QByteArray data; - QBuffer buffer(&data); - QDataStream stream(&buffer); - buffer.open(QIODevice::ReadWrite); - - stream << m_mainWindows.count(); - for (int i = 0; i < m_mainWindows.count(); ++i) + // set Icon Database Path to store "favicons" associated with web sites + QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + if ( directory.isEmpty() ) { - stream << m_mainWindows.at(i)->saveState(); + directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); } - - group.writeEntry( QString("lastSession"), data ); -} - + QWebSettings::setIconDatabasePath(directory); -bool Application::canRestoreSession() const -{ - return !m_lastSession.isEmpty(); + Application::historyManager(); } -void Application::restoreLastSession() +void Application::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) { - QList windows; - QBuffer buffer(&m_lastSession); - QDataStream stream(&buffer); - buffer.open(QIODevice::ReadOnly); - int windowCount; - stream >> windowCount; - for (int i = 0; i < windowCount; ++i) - { - QByteArray windowState; - stream >> windowState; - windows.append(windowState); - } - for (int i = 0; i < windows.count(); ++i) - { - MainWindow *newWindow = 0; - if (m_mainWindows.count() == 1 - && mainWindow()->tabWidget()->count() == 1 - && mainWindow()->currentTab()->url() == KUrl()) - { - newWindow = mainWindow(); - } - else - { - newWindow = newMainWindow(); - } - newWindow->restoreState(windows.at(i)); - } + new Download( srcUrl, destUrl ); } - -bool Application::isTheOnlyBrowser() const -{ - return (m_localServer != 0); -} +// void Application::saveSession() +// { +// QWebSettings *globalSettings = QWebSettings::globalSettings(); +// if ( globalSettings->testAttribute( QWebSettings::PrivateBrowsingEnabled ) ) +// return; +// +// KConfig config("rekonqrc"); +// KConfigGroup group = config.group("sessions"); +// QByteArray data; +// QBuffer buffer(&data); +// QDataStream stream(&buffer); +// buffer.open(QIODevice::ReadWrite); +// +// stream << m_mainWindows.count(); +// for (int i = 0; i < m_mainWindows.count(); ++i) +// { +// stream << m_mainWindows.at(i)->saveState(); +// } +// +// group.writeEntry( QString("lastSession"), data ); +// } void Application::openUrl(const KUrl &url) @@ -254,43 +197,36 @@ void Application::openUrl(const KUrl &url) } - -MainWindow *Application::newMainWindow() +MainWindow *Application::mainWindow() { - MainWindow *browser = new MainWindow(); - m_mainWindows.prepend(browser); - browser->show(); - return browser; + return m_mainWindow; } -MainWindow *Application::mainWindow() +WebView *Application::newTab() { - clean(); - if (m_mainWindows.isEmpty()) - newMainWindow(); - return m_mainWindows[0]; + return m_mainWindow->tabWidget()->newTab(); } -void Application::newLocalSocketConnection() -{ - QLocalSocket *socket = m_localServer->nextPendingConnection(); - if (!socket) - return; - socket->waitForReadyRead(1000); - QTextStream stream(socket); - QString url; - stream >> url; - if (!url.isEmpty()) - { - mainWindow()->tabWidget()->newTab(); - openUrl(url); - } - delete socket; - mainWindow()->raise(); - mainWindow()->activateWindow(); -} +// void Application::newLocalSocketConnection() +// { +// QLocalSocket *socket = m_localServer->nextPendingConnection(); +// if (!socket) +// return; +// socket->waitForReadyRead(1000); +// QTextStream stream(socket); +// QString url; +// stream >> url; +// if (!url.isEmpty()) +// { +// mainWindow()->tabWidget()->newTab(); +// openUrl(url); +// } +// delete socket; +// mainWindow()->raise(); +// mainWindow()->activateWindow(); +// } @@ -323,8 +259,6 @@ HistoryManager *Application::historyManager() } - - KIcon Application::icon(const KUrl &url) const { KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); diff --git a/src/application.h b/src/application.h index 32d810f0..30f1cc5b 100644 --- a/src/application.h +++ b/src/application.h @@ -22,7 +22,7 @@ #define REKONQ_APPLICATION_H // KDE Includes -#include +#include #include #include #include @@ -38,53 +38,53 @@ class QLocalServer; QT_END_NAMESPACE class MainWindow; +class WebView; class CookieJar; class HistoryManager; class NetworkAccessManager; -/* - * - */ -class Application : public KApplication +/** + * + */ +class Application : public KUniqueApplication { Q_OBJECT public: - Application(KCmdLineArgs*, const QString &); + Application(); ~Application(); + int newInstance(); static Application *instance(); - bool isTheOnlyBrowser() const; MainWindow *mainWindow(); - QList mainWindows(); + WebView* newTab(); + KIcon icon(const KUrl &url) const; - void downloadUrl(const KUrl &srcUrl, const KUrl &destUrl); - void saveSession(); - bool canRestoreSession() const; + /** + * This method lets you to download a file from a source remote url + * to a local destination url. + */ + void downloadUrl(const KUrl &srcUrl, const KUrl &destUrl); static HistoryManager *historyManager(); static CookieJar *cookieJar(); static NetworkAccessManager *networkAccessManager(); -public slots: - MainWindow *newMainWindow(); - void restoreLastSession(); - private slots: + + /** + * Any actions that can be delayed until the window is visible + */ void postLaunch(); void openUrl(const KUrl &url); - void newLocalSocketConnection(); +// void newLocalSocketConnection(); private: - void clean(); - static HistoryManager *s_historyManager; static NetworkAccessManager *s_networkAccessManager; - QList > m_mainWindows; - QLocalServer *m_localServer; - QByteArray m_lastSession; + MainWindow* m_mainWindow; mutable KIcon m_defaultIcon; }; diff --git a/src/main.cpp b/src/main.cpp index 9a779783..a97bb0d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,11 +23,12 @@ #include #include +#include static const char description[] = I18N_NOOP("KDE Browser Webkit Based"); -static const char version[] = "0.0.3"; +static const char version[] = "0.0.4"; int main(int argc, char **argv) { @@ -53,13 +54,14 @@ int main(int argc, char **argv) KCmdLineOptions options; options.add( "+URL" , ki18n("Location to open") ); KCmdLineArgs::addCmdLineOptions( options ); + Application::addCmdLineOptions(); - KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); - - Application app(args, "rekonq"); - if (!app.isTheOnlyBrowser()) - return 0; - app.newMainWindow(); + if (!Application::start()) + { + kWarning() << "rekonq is already running!"; + return 0; + } + Application app; return app.exec(); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ee028abb..91ee8028 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -74,9 +74,6 @@ MainWindow::MainWindow() // updating rekonq configuration slotUpdateConf(); - // creating a new tab - m_view->newTab(); - // creating a centralWidget containing m_view and the hidden findbar QWidget *centralWidget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; @@ -444,9 +441,8 @@ void MainWindow::slotUpdateWindowTitle(const QString &title) void MainWindow::slotFileNew() { - Application::instance()->newMainWindow(); - MainWindow *mw = Application::instance()->mainWindow(); - mw->slotHome(); + Application::instance()->newTab(); + slotHome(); } @@ -520,13 +516,9 @@ void MainWindow::slotPrivateBrowsing() { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); - QList windows = Application::instance()->mainWindows(); - for (int i = 0; i < windows.count(); ++i) - { - MainWindow *window = windows.at(i); - window->m_lastSearch = QString::null; - window->tabWidget()->clear(); - } + MainWindow* win = Application::instance()->mainWindow(); + win->m_lastSearch = QString::null; + win->tabWidget()->clear(); } } @@ -726,22 +718,6 @@ void MainWindow::slotAboutToShowBackMenu() } -// void MainWindow::slotShowWindow() -// { -// if (KAction *action = qobject_cast(sender())) -// { -// QVariant v = action->data(); -// if (v.canConvert()) -// { -// int offset = qvariant_cast(v); -// QList windows = Application::instance()->mainWindows(); -// windows.at(offset)->activateWindow(); -// windows.at(offset)->currentTab()->setFocus(); -// } -// } -// } - - void MainWindow::slotOpenActionUrl(QAction *action) { int offset = action->data().toInt(); diff --git a/src/webview.cpp b/src/webview.cpp index ab8ef5cd..850ff54b 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -76,21 +76,8 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if ( type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) ) { - bool newWindow = (m_keyboardModifiers & Qt::AltModifier); - WebView *webView; - if (newWindow) - { - Application::instance()->newMainWindow(); - MainWindow *newMainWindow = Application::instance()->mainWindow(); - webView = newMainWindow->currentTab(); - newMainWindow->raise(); - newMainWindow->activateWindow(); - webView->setFocus(); - } - else - { - webView = mainWindow()->tabWidget()->newTab( true ); - } + WebView *webView = Application::instance()->newTab(); + webView->setFocus(); webView->load(request); m_keyboardModifiers = Qt::NoModifier; m_pressedButtons = Qt::NoButton; @@ -109,13 +96,16 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) { Q_UNUSED(type); if (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) + { m_openInNewTab = true; + } + if (m_openInNewTab) { m_openInNewTab = false; return mainWindow()->tabWidget()->newTab()->page(); } - Application::instance()->newMainWindow(); + MainWindow *mainWindow = Application::instance()->mainWindow(); return mainWindow->currentTab()->page(); } -- cgit v1.2.1 From 2b2b65ddca10b8e620825c2e91d2776752890415 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 20 Feb 2009 15:12:34 +0100 Subject: typo --- src/application.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/application.h b/src/application.h index 30f1cc5b..73e800e9 100644 --- a/src/application.h +++ b/src/application.h @@ -3,7 +3,6 @@  * This file is a part of the rekonq project  * * Copyright (C) 2008 by Andrea Diamantini - * *  * This program is free software; you can redistribute it  * and/or modify it under the terms of the GNU General -- cgit v1.2.1 From f168eab1529acb33d48857e29c6ddf22a626f41b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 20 Feb 2009 18:05:22 +0100 Subject: On the street to SingleRekonq.. --- src/application.cpp | 1 + src/mainwindow.cpp | 2 ++ src/mainwindow.h | 1 - 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/application.cpp b/src/application.cpp index d6679b97..889ec51f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -110,6 +110,7 @@ Application::Application() Application::~Application() { + delete m_mainWindow; delete s_networkAccessManager; } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 91ee8028..213d3a84 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -145,6 +145,8 @@ MainWindow::MainWindow() MainWindow::~MainWindow() { + delete m_view; + delete m_bookmarksProvider; } diff --git a/src/mainwindow.h b/src/mainwindow.h index fa96eb0e..1a1d14d1 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -86,7 +86,6 @@ private slots: void slotSwapFocus();*/ - // File Menu slots void slotFileNew(); void slotFileOpen(); -- cgit v1.2.1 From 75310e79287a8bdffb86cc1dfda1a0f069383cd6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 20 Feb 2009 19:06:41 +0100 Subject: Last commit before branching "di brutto".. --- src/application.cpp | 40 +--------------------------------------- src/mainview.cpp | 4 +--- src/mainwindow.cpp | 7 +++++-- src/mainwindow.h | 6 ------ src/webview.cpp | 21 +++++++++++++-------- src/webview.h | 2 +- 6 files changed, 21 insertions(+), 59 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 889ec51f..cc237823 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -61,48 +61,10 @@ NetworkAccessManager *Application::s_networkAccessManager = 0; Application::Application() : KUniqueApplication() -// , m_localServer(0) { m_mainWindow = new MainWindow(); - m_mainWindow->show(); - -// QLocalSocket socket; -// socket.connectToServer(serverName); -// if (socket.waitForConnected(500)) -// { -// QTextStream stream(&socket); -// int n = args->count(); -// if (n > 1) -// stream << args->arg(n-1); -// else -// stream << QString(); -// stream.flush(); -// socket.waitForBytesWritten(); -// return; -// } -// -// KApplication::setQuitOnLastWindowClosed(true); -// -// m_localServer = new QLocalServer(this); -// connect(m_localServer, SIGNAL(newConnection()), this, SLOT(newLocalSocketConnection())); -// if (!m_localServer->listen(serverName)) -// { -// if (m_localServer->serverError() == QAbstractSocket::AddressInUseError -// && QFile::exists(m_localServer->serverName())) -// { -// QFile::remove(m_localServer->serverName()); -// m_localServer->listen(serverName); -// } -// } -// -// QDesktopServices::setUrlHandler(QLatin1String("http"), this, "openUrl"); -// QString localSysName = QLocale::system().name(); -// -// KConfig config("rekonqrc"); -// KConfigGroup group = config.group("sessions"); -// m_lastSession = group.readEntry( QString("lastSession"), QByteArray() ); - setWindowIcon( KIcon("rekonq") ); + m_mainWindow->show(); QTimer::singleShot(0, this, SLOT( postLaunch() ) ); } diff --git a/src/mainview.cpp b/src/mainview.cpp index a3030748..cb84f56b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -48,7 +48,7 @@ MainView::MainView(QWidget *parent) , m_recentlyClosedTabsAction(0) , m_recentlyClosedTabsMenu(0) , m_lineEditCompleter(0) - , m_lineEdits(0) + , m_lineEdits(new QStackedWidget(this)) , m_tabBar(new TabBar(this)) { setElideMode(Qt::ElideRight); @@ -72,8 +72,6 @@ MainView::MainView(QWidget *parent) // -- connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); - - m_lineEdits = new QStackedWidget(this); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 213d3a84..07b0fb9c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -65,9 +65,12 @@ MainWindow::MainWindow() : KXmlGuiWindow() - , m_view( new MainView(this) ) - , m_bookmarksProvider( new BookmarksProvider(this) ) + , m_view(0) + , m_bookmarksProvider(0) { + m_view = new MainView(this); + m_bookmarksProvider = new BookmarksProvider(this); + // accept dnd setAcceptDrops(true); diff --git a/src/mainwindow.h b/src/mainwindow.h index 1a1d14d1..a1f4464b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -117,18 +117,12 @@ private slots: private: SearchBar *m_searchBar; FindBar *m_findBar; - KMenu *m_historyBackMenu; KMenu *m_windowMenu; - BookmarksProvider *m_bookmarksProvider; - QAction *m_stopReload; - QString m_lastSearch; - MainView *m_view; - QString m_homePage; }; diff --git a/src/webview.cpp b/src/webview.cpp index 850ff54b..b90f85cc 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -111,14 +111,19 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) } -QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) -{ - Q_UNUSED(url); - Q_UNUSED(paramNames); - Q_UNUSED(paramValues); - QUiLoader loader; - return loader.createWidget(classId, view()); -} +// QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +// { +// kWarning() << "creating PLUGIN for rekonq "; +// kWarning() << "classId = " << classId; +// kWarning() << "url = " << url; +// kWarning() << "Param Names = " << paramNames; +// kWarning() << "Param Values = " << paramValues; +// Q_UNUSED(url); +// Q_UNUSED(paramNames); +// Q_UNUSED(paramValues); +// QUiLoader loader; +// return loader.createWidget(classId, view()); +// } void WebPage::handleUnsupportedContent(QNetworkReply *reply) diff --git a/src/webview.h b/src/webview.h index 6892fbd4..b45edc17 100644 --- a/src/webview.h +++ b/src/webview.h @@ -50,7 +50,7 @@ public: protected: bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); QWebPage *createWindow(QWebPage::WebWindowType type); - QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); +// QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); private slots: void handleUnsupportedContent(QNetworkReply *reply); -- cgit v1.2.1 From f2fc94f76377e5ccfec9469862f02d5461798c6e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 20 Feb 2009 19:42:57 +0100 Subject: removed unuseful m_defaultIcon --- src/application.cpp | 31 +++++-------------------------- src/application.h | 1 - 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index cc237823..53825411 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -172,27 +172,6 @@ WebView *Application::newTab() } -// void Application::newLocalSocketConnection() -// { -// QLocalSocket *socket = m_localServer->nextPendingConnection(); -// if (!socket) -// return; -// socket->waitForReadyRead(1000); -// QTextStream stream(socket); -// QString url; -// stream >> url; -// if (!url.isEmpty()) -// { -// mainWindow()->tabWidget()->newTab(); -// openUrl(url); -// } -// delete socket; -// mainWindow()->raise(); -// mainWindow()->activateWindow(); -// } - - - CookieJar *Application::cookieJar() { return (CookieJar*)networkAccessManager()->cookieJar(); @@ -225,10 +204,10 @@ HistoryManager *Application::historyManager() KIcon Application::icon(const KUrl &url) const { KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); - if (!icon.isNull()) - return icon; - if (m_defaultIcon.isNull()) - m_defaultIcon = KIcon("kde"); - return m_defaultIcon; + if (icon.isNull()) + { + icon = KIcon("kde"); + } + return icon; } diff --git a/src/application.h b/src/application.h index 73e800e9..0c29b72b 100644 --- a/src/application.h +++ b/src/application.h @@ -84,7 +84,6 @@ private: static NetworkAccessManager *s_networkAccessManager; MainWindow* m_mainWindow; - mutable KIcon m_defaultIcon; }; #endif // REKONQ_APPLICATION_H -- cgit v1.2.1 From e6d902eb8dc2d6815d4606519b638c6ec0f435e2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 21 Feb 2009 11:17:38 +0100 Subject: It seems good now. But we have to test it a lot with Qt 4.5.. --- src/application.cpp | 27 +++------------------------ src/application.h | 8 -------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 53825411..c4b4b38f 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -63,6 +63,7 @@ Application::Application() : KUniqueApplication() { m_mainWindow = new MainWindow(); + m_mainWindow->setObjectName("MainWindow"); setWindowIcon( KIcon("rekonq") ); m_mainWindow->show(); @@ -72,8 +73,9 @@ Application::Application() Application::~Application() { - delete m_mainWindow; delete s_networkAccessManager; + delete s_historyManager; + delete m_mainWindow; } @@ -131,29 +133,6 @@ void Application::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) } -// void Application::saveSession() -// { -// QWebSettings *globalSettings = QWebSettings::globalSettings(); -// if ( globalSettings->testAttribute( QWebSettings::PrivateBrowsingEnabled ) ) -// return; -// -// KConfig config("rekonqrc"); -// KConfigGroup group = config.group("sessions"); -// QByteArray data; -// QBuffer buffer(&data); -// QDataStream stream(&buffer); -// buffer.open(QIODevice::ReadWrite); -// -// stream << m_mainWindows.count(); -// for (int i = 0; i < m_mainWindows.count(); ++i) -// { -// stream << m_mainWindows.at(i)->saveState(); -// } -// -// group.writeEntry( QString("lastSession"), data ); -// } - - void Application::openUrl(const KUrl &url) { mainWindow()->loadUrl(url); diff --git a/src/application.h b/src/application.h index 0c29b72b..7a08eb1a 100644 --- a/src/application.h +++ b/src/application.h @@ -29,13 +29,6 @@ #include #include -// Qt Includes -#include - -QT_BEGIN_NAMESPACE -class QLocalServer; -QT_END_NAMESPACE - class MainWindow; class WebView; class CookieJar; @@ -77,7 +70,6 @@ private slots: */ void postLaunch(); void openUrl(const KUrl &url); -// void newLocalSocketConnection(); private: static HistoryManager *s_historyManager; -- cgit v1.2.1 From a235af4b07114a97cc0221f236e075cd61014a4d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 24 Feb 2009 11:49:35 +0100 Subject: New Icons! --- icons/hi16-app-rekonq.png | Bin 832 -> 887 bytes icons/hi32-app-rekonq.png | Bin 1719 -> 2269 bytes icons/hi64-app-rekonq.png | Bin 5650 -> 6071 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/icons/hi16-app-rekonq.png b/icons/hi16-app-rekonq.png index e557f173..2427ffef 100644 Binary files a/icons/hi16-app-rekonq.png and b/icons/hi16-app-rekonq.png differ diff --git a/icons/hi32-app-rekonq.png b/icons/hi32-app-rekonq.png index 8d87115a..110c6017 100644 Binary files a/icons/hi32-app-rekonq.png and b/icons/hi32-app-rekonq.png differ diff --git a/icons/hi64-app-rekonq.png b/icons/hi64-app-rekonq.png index 312b572a..74d350a5 100644 Binary files a/icons/hi64-app-rekonq.png and b/icons/hi64-app-rekonq.png differ -- cgit v1.2.1 From 1388bed0effca69e1fee0fb080eb035a3653f4c1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 24 Feb 2009 11:50:03 +0100 Subject: Documented API bookmarks && download classes. Fixed load on startup --- TODO | 10 +++++++ src/application.cpp | 18 ++++------- src/bookmarks.cpp | 4 ++- src/bookmarks.h | 86 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/download.h | 17 ++++++++++- 5 files changed, 114 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index ce205bcd..93ae6959 100644 --- a/TODO +++ b/TODO @@ -10,6 +10,16 @@ To 0.0.4 - contextMenu in searchbar to set different search engines - KDE proxy support - QWebPluginFactory subclass to load KParts into QtWebKit. + + ------------------------ +1. check the lines above... +2. Improve docs +3. Let rekonq be a Singleton app. (And work well..) +4. fix bookmarks toolbar POSITION +5. fix bookmarks action menu (in toolbar) +6. fix load at startup +7. fix FONTS problems between webkit && KDE settings (at least, here..) +8. enable flash support !! ++ ------------------------ \ No newline at end of file diff --git a/src/application.cpp b/src/application.cpp index c4b4b38f..315c5cf1 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -65,6 +65,9 @@ Application::Application() m_mainWindow = new MainWindow(); m_mainWindow->setObjectName("MainWindow"); setWindowIcon( KIcon("rekonq") ); + newTab(); + mainWindow()->slotHome(); + m_mainWindow->show(); QTimer::singleShot(0, this, SLOT( postLaunch() ) ); @@ -75,7 +78,6 @@ Application::~Application() { delete s_networkAccessManager; delete s_historyManager; - delete m_mainWindow; } @@ -83,7 +85,7 @@ int Application::newInstance() { KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - static bool first = true; + if (args->count() > 0) { for (int i = 0; i < args->count(); ++i) @@ -92,17 +94,9 @@ int Application::newInstance() newTab(); mainWindow()->loadUrl( url ); } + args->clear(); } - else - { - if( !first || !isSessionRestored()) - { - newTab(); - mainWindow()->slotHome(); - } - } - first = false; - args->clear(); + return 0; } diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index 584b2689..a2ebf08a 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -37,8 +37,10 @@ OwnBookMarks::OwnBookMarks(KMainWindow *parent) } -void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons , Qt::KeyboardModifiers ) +void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons mb, Qt::KeyboardModifiers km) { + Q_UNUSED(mb); + Q_UNUSED(km); emit openUrl( b.url() ); } diff --git a/src/bookmarks.h b/src/bookmarks.h index aa18834c..825c0d3a 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -31,40 +31,112 @@ class MainWindow; -/* +/** + * Inherited from KBookmarkOwner, this class allows to manage + * bookmarks as actions * + * @author Andrea Diamantini + * @since 4.x */ class OwnBookMarks : public QObject , public KBookmarkOwner { Q_OBJECT + public: - OwnBookMarks(KMainWindow *); - virtual void openBookmark (const KBookmark & , Qt::MouseButtons , Qt::KeyboardModifiers ); + /** + * The class ctor. + * + * @param parent the pointer to the browser mainwindow. We need it + * to link bookmarks actions with the right window + * where load url in + */ + OwnBookMarks(KMainWindow *parent); + + /** + * This function is called when a bookmark is selected and belongs to + * the ancestor class. + * This method actually emits signal to load bookmark's url without + * considering mousebuttons or keyboard modifiers. + * + * @param b the bookmark to open + * @param mb the mouse buttons clicked to select the bookmark + * @param km the keyboard modifiers pushed when the bookmark was selected + */ + virtual void openBookmark (const KBookmark &b , Qt::MouseButtons mb, Qt::KeyboardModifiers km); - // KBookmarkOwner interface: + + /** + * this method, from KBookmarkOwner interface, allows to add the current page + * to the bookmark list, returning the URL page as QString. + * + * @return the current page's URL + */ virtual QString currentUrl() const; + + /** + * this method, from KBookmarkOwner interface, allows to add the current page + * to the bookmark list, returning the title's page as QString. + * + * @return the current page's title + */ virtual QString currentTitle() const; signals: + /** + * This signal is emitted when an url has to be loaded + * + * @param url the URL to load + * + */ void openUrl(const KUrl &); private: + // the MainWindow pointer MainWindow *m_parent; }; + // ------------------------------------------------------------------------------ -/* + +/** + * This class represent the interface to rekonq bookmarks system. + * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided + * from this class. + * So it implements code to have each one + * + * @author Andrea Diamantini + * @since 4.x * */ class BookmarksProvider : public QObject { Q_OBJECT + public: - BookmarksProvider(KMainWindow*); + /** + * Class constructor. Connect BookmarksProvider with bookmarks source + * (actually konqueror's bookmarks) + * + * @param parent The MainWindow to provide bookmarks objects + * + */ + BookmarksProvider(KMainWindow* parent); + + /** + * Customize bookmarks toolbar + * + * @param toolbar the toolbar to customize + */ + void provideBmToolbar(KToolBar* toolbar); - void provideBmToolbar(KToolBar*); + /** + * Generate the Bookmarks Menu + * + * @return the Bookmarks Menu + * + */ KMenu *bookmarksMenu(); private: diff --git a/src/download.h b/src/download.h index cd363d00..a3ce9d23 100644 --- a/src/download.h +++ b/src/download.h @@ -29,16 +29,31 @@ #include #include -/* +/** * This class lets rekonq to download an object from the network. * Creating a new object, you can continue downloading a file also * when rekonq is closed. + * */ class Download : public QObject { Q_OBJECT public: + /** + * Class constructor. This is the unique method we need to + * use this class. In fact Download class needs to know just + * "where" catch the file to download and where it has to put it + * + * @param srcUrl the source url + * + * @param destUrl the destination url + * + */ Download(const KUrl &srcUrl, const KUrl &destUrl); + + /** + * class destructor + */ ~Download(); private slots: -- cgit v1.2.1 From 5e6be36618dd2e9f9dd64ffd2ed899ec4dc55f2c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 25 Feb 2009 12:05:15 +0100 Subject: 1st fixes to bookmarks system, toolbar and menu. Needs care and docs.. --- src/bookmarks.cpp | 41 +++++++++++++++++++++++++++++++++++++---- src/bookmarks.h | 26 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index a2ebf08a..2c1b4afc 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -61,9 +61,25 @@ QString OwnBookMarks::currentTitle() const // ------------------------------------------------------------------------------------------------------ +BookmarksMenu::BookmarksMenu( KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac ) + : KBookmarkMenu(manager, owner, menu, ac) +{ +} + +KMenu* BookmarksMenu::viewContextMenu(QAction* action) +{ + return contextMenu( action ); +} + + +// ------------------------------------------------------------------------------------------------------ + + BookmarksProvider::BookmarksProvider(KMainWindow* parent) : m_parent(parent) - , m_owner(new OwnBookMarks(parent)) + , m_owner(new OwnBookMarks(parent)) + , m_bmMenu(0) + , m_bmToolbar(0) { KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); @@ -73,7 +89,12 @@ BookmarksProvider::BookmarksProvider(KMainWindow* parent) void BookmarksProvider::provideBmToolbar(KToolBar* toolbar) { + m_bmToolbar = toolbar; toolbar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); + + toolbar->setContextMenuPolicy( Qt::CustomContextMenu ); + connect( toolbar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &)) ); + KBookmarkGroup toolbarGroup = m_manager->toolbar(); KBookmark bm = toolbarGroup.first(); while(!bm.isNull()) @@ -102,8 +123,20 @@ void BookmarksProvider::provideBmToolbar(KToolBar* toolbar) KMenu *BookmarksProvider::bookmarksMenu() { - KMenu *bmMenu = new KMenu(m_parent); - new KBookmarkMenu( m_manager, m_owner, bmMenu, m_ac ); - return bmMenu; + KMenu *menu = new KMenu(m_parent); + m_bmMenu = new BookmarksMenu( m_manager, m_owner, menu, m_ac ); + return menu; +} + + +void BookmarksProvider::contextMenu(const QPoint & point) +{ + KAction* action = dynamic_cast( m_bmToolbar->actionAt( point ) ); + if(!action) + return; + KMenu *menu = m_bmMenu->viewContextMenu(action); + menu->setAttribute(Qt::WA_DeleteOnClose); + menu->popup( m_bmToolbar->mapToGlobal( point )); } + diff --git a/src/bookmarks.h b/src/bookmarks.h index 825c0d3a..f9f3e91c 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -97,6 +97,26 @@ private: }; +// ------------------------------------------------------------------------------ + +/** + * This class represent the rekonq bookmarks menu. + * It's just a simple class inherited from KBookmarkMenu + * + * @author Andrea Diamantini + * @since 4.x + * + */ +class BookmarksMenu : public KBookmarkMenu +{ +Q_OBJECT + +public: + BookmarksMenu( KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac); + + KMenu *viewContextMenu(QAction* action); +}; + // ------------------------------------------------------------------------------ @@ -139,10 +159,16 @@ public: */ KMenu *bookmarksMenu(); +public slots: + void contextMenu(const QPoint & point); + private: KMainWindow *m_parent; OwnBookMarks *m_owner; KBookmarkManager *m_manager; KActionCollection *m_ac; + BookmarksMenu *m_bmMenu; + KToolBar *m_bmToolbar; }; + #endif -- cgit v1.2.1 From 90c6462e87b38b5c98b6eba7dc282fb234afbe23 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 26 Feb 2009 00:16:52 +0100 Subject: QDesktopServices --> KStandardDirs --- src/application.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 315c5cf1..7475f1c6 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -37,6 +37,7 @@ // KDE Includes #include #include +#include #include #include #include @@ -45,13 +46,11 @@ #include #include #include -#include #include -#include -#include #include #include #include +#include @@ -110,7 +109,7 @@ Application *Application::instance() void Application::postLaunch() { // set Icon Database Path to store "favicons" associated with web sites - QString directory = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString directory = KStandardDirs::locateLocal( "cache" , "" , true ); if ( directory.isEmpty() ) { directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); -- cgit v1.2.1 From 47a176f65c04d08cd8e54eab56a664532638f49a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 26 Feb 2009 00:27:39 +0100 Subject: Removed unuseful headers --- src/application.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/application.cpp b/src/application.cpp index 7475f1c6..9495ae29 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -50,7 +50,6 @@ #include #include #include -#include -- cgit v1.2.1 From ea94738bf6c59ce254a6f177e978814019c856a4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 1 Mar 2009 12:10:53 +0100 Subject: Fixing Font Troubles. Try 1.. --- src/mainwindow.cpp | 24 +++++++++++++++++++++--- src/mainwindow.h | 5 ----- src/settings.cpp | 3 +++ src/webview.cpp | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 07b0fb9c..5a591883 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -51,6 +51,8 @@ #include #include #include +#include + // Qt Includes #include @@ -302,12 +304,28 @@ void MainWindow::slotUpdateConf() m_homePage = ReKonfig::homePage(); // =========== Fonts ============== - QFont standardFont = ReKonfig::standardFont(); - QFont fixedFont = ReKonfig::fixedFont(); - QWebSettings *defaultSettings = QWebSettings::globalSettings(); + + QFont standardFont = ReKonfig::standardFont(); + if( !standardFont.exactMatch() ) + { + kWarning() << "Webkit Standard Font doesn't match! Setting to KDE general font.."; + standardFont = KGlobalSettings::generalFont(); + ReKonfig::setStandardFont( standardFont ); + ReKonfig::self()->writeConfig(); + } defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); + + + QFont fixedFont = ReKonfig::fixedFont(); + if( !fixedFont.exactMatch() ) + { + kWarning() << "Webkit Fixed Font doesn't match! Setting to KDE fixed font.."; + fixedFont = KGlobalSettings::fixedFont(); + ReKonfig::setFixedFont( fixedFont ); + ReKonfig::self()->writeConfig(); + } defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); diff --git a/src/mainwindow.h b/src/mainwindow.h index a1f4464b..4864f347 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -46,7 +46,6 @@ class WebView; * It handles the menus, toolbars, and status bars. * */ - class MainWindow : public KXmlGuiWindow { Q_OBJECT @@ -82,10 +81,6 @@ private slots: void slotOpenPrevious(); void slotOpenNext(); -/* void slotShowWindow(); - void slotSwapFocus();*/ - - // File Menu slots void slotFileNew(); void slotFileOpen(); diff --git a/src/settings.cpp b/src/settings.cpp index f5476ad3..7be3e1fa 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -156,6 +156,9 @@ void SettingsDialog::saveSettings() // Fonts ReKonfig::setStandardFont( d->fontsUi.standardFontChooser->font() ); ReKonfig::setFixedFont( d->fontsUi.standardFontChooser->font() ); + + // Save + ReKonfig::self()->writeConfig(); } diff --git a/src/webview.cpp b/src/webview.cpp index b90f85cc..e6748263 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -40,9 +40,9 @@ #include #include #include -#include #include // --- +#include #include WebPage::WebPage(QObject *parent) -- cgit v1.2.1 From 832e97b04d399492c6e997395ea0dbd1f731ec92 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 1 Mar 2009 12:17:17 +0100 Subject: Updating CMakeLists.txt --- CMakeLists.txt | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56d8f9b3..eea4c3e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,9 @@ PROJECT( rekonq ) # rekonq version SET(REKONQ_MAJOR_VERSION "0") SET(REKONQ_MINOR_VERSION "0") -SET(REKONQ_PATCH_VERSION "3") +SET(REKONQ_PATCH_VERSION "4") -SET(REKONQ_VERSION_STRING +SET(REKONQ_VERSION_STR "${REKONQ_MAJOR_VERSION}.${REKONQ_MINOR_VERSION}.${REKONQ_PATCH_VERSION}" ) @@ -37,18 +37,23 @@ INCLUDE(MacroLibrary) MESSAGE(STATUS "") MESSAGE(STATUS "----------------------------------------------------------------------------------") -MESSAGE(STATUS " rekonq ${REKONQ_VERSION_STRING} dependencies results ") +MESSAGE(STATUS " rekonq ${REKONQ_VERSION_STR} dependencies results ") MESSAGE(STATUS "") # Require shared libraries results. +SET(QT_VERS_STR + "${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}" + ) + IF(QT_FOUND) MESSAGE(STATUS " Qt library found............... YES") + MESSAGE(STATUS " Qt version ${QT_VERS_STR} found! ") ELSE(QT_FOUND) MESSAGE(STATUS " Qt library found............... NO") MESSAGE(STATUS "") - MESSAGE(SEND_ERROR " rekonq needs at least Qt 4.4.0. Please install it and try compiling again.") - MESSAGE(STATUS " Qt website is at http://www.trolltech.com") + MESSAGE(SEND_ERROR " rekonq needs at least Qt ${QT_MIN_VERSION}. Please install it and try compiling again.") + MESSAGE(STATUS " Qt website is at http://www.qtsoftware.com") MESSAGE(STATUS "") ENDIF(QT_FOUND) -- cgit v1.2.1 From 0b8ee38c5326fa668906a3f66a959423d84f85d1 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 10 Mar 2009 23:05:09 +0100 Subject: Some fixes --- src/mainwindow.cpp | 1 - src/settings_privacy.ui | 89 +++++++++++++++++++++++++------------------------ src/webview.cpp | 20 +++++------ src/webview.h | 2 +- 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5a591883..98ce7d99 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -151,7 +151,6 @@ MainWindow::MainWindow() MainWindow::~MainWindow() { delete m_view; - delete m_bookmarksProvider; } diff --git a/src/settings_privacy.ui b/src/settings_privacy.ui index 19e7f088..7f3ff1a8 100644 --- a/src/settings_privacy.ui +++ b/src/settings_privacy.ui @@ -1,7 +1,8 @@ - + + privacy - - + + 0 0 @@ -9,32 +10,32 @@ 313 - + Privacy - + - - + + Web Content - + - - + + Enable Plugins - + true - - + + Enable Javascript - + true @@ -43,79 +44,79 @@ - - + + Cookies - - - - + + + + Accept Cookies: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + Always - + Never - + Only from sites you navigate to - - - + + + Exceptions... - - - + + + Keep until: - + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - + + - + They expire - + I exit the application - + At most 90 days - - - + + + Cookies... @@ -124,11 +125,11 @@ - - + + Qt::Vertical - + 20 40 diff --git a/src/webview.cpp b/src/webview.cpp index e6748263..0c2e0b6e 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -111,19 +111,19 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) } -// QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) -// { -// kWarning() << "creating PLUGIN for rekonq "; -// kWarning() << "classId = " << classId; -// kWarning() << "url = " << url; -// kWarning() << "Param Names = " << paramNames; -// kWarning() << "Param Values = " << paramValues; +QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) +{ + kWarning() << "creating PLUGIN for rekonq "; + kWarning() << "classId = " << classId; + kWarning() << "url = " << url; + kWarning() << "Param Names = " << paramNames; + kWarning() << "Param Values = " << paramValues; // Q_UNUSED(url); // Q_UNUSED(paramNames); // Q_UNUSED(paramValues); -// QUiLoader loader; -// return loader.createWidget(classId, view()); -// } + QUiLoader loader; + return loader.createWidget(classId, view()); +} void WebPage::handleUnsupportedContent(QNetworkReply *reply) diff --git a/src/webview.h b/src/webview.h index b45edc17..6892fbd4 100644 --- a/src/webview.h +++ b/src/webview.h @@ -50,7 +50,7 @@ public: protected: bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type); QWebPage *createWindow(QWebPage::WebWindowType type); -// QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); + QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues); private slots: void handleUnsupportedContent(QNetworkReply *reply); -- cgit v1.2.1 From 963fc785301e378096fc53648e972c57a962c0dd Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Mar 2009 00:07:49 +0100 Subject: Some fixes on MainWindow --- src/mainwindow.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 98ce7d99..f28450fe 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -67,18 +67,15 @@ MainWindow::MainWindow() : KXmlGuiWindow() - , m_view(0) - , m_bookmarksProvider(0) + , m_view( new MainView(this) ) + , m_bookmarksProvider( new BookmarksProvider(this) ) { - m_view = new MainView(this); - m_bookmarksProvider = new BookmarksProvider(this); - // accept dnd setAcceptDrops(true); // updating rekonq configuration slotUpdateConf(); - + // creating a centralWidget containing m_view and the hidden findbar QWidget *centralWidget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; @@ -92,6 +89,13 @@ MainWindow::MainWindow() centralWidget->setLayout(layout); setCentralWidget(centralWidget); + // setting size policies + QRect desktopRect = QApplication::desktop()->screenGeometry(); + QSize size = desktopRect.size() * 0.8; + setMinimumSize( size ); + + setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + // connect signals and slots connect(m_view, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); connect(m_view, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); @@ -139,7 +143,7 @@ MainWindow::MainWindow() m_bookmarksProvider->provideBmToolbar( bmToolbar ); // setting up toolbars to NOT have context menu enabled - setContextMenuPolicy( Qt::ActionsContextMenu ); + setContextMenuPolicy( Qt::DefaultContextMenu ); // search bar m_searchBar = new SearchBar( this ); @@ -296,7 +300,6 @@ void MainWindow::setupHistoryMenu() } -// TODO FIXME void MainWindow::slotUpdateConf() { // ============== General ================== -- cgit v1.2.1 From b5044060c9263d223c99055b9bd6b93c9fb966c7 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Mar 2009 00:55:47 +0100 Subject: Forwarding class declarations to speed up compilation.. --- src/application.h | 1 + src/mainview.cpp | 6 +++++- src/mainview.h | 22 +++++++++++----------- src/mainwindow.cpp | 12 ++++-------- src/mainwindow.h | 15 ++++++++------- src/networkaccessmanager.h | 4 +++- src/searchbar.cpp | 6 ++++++ src/searchbar.h | 9 +++++---- src/settings.h | 4 ++-- src/urlbar.cpp | 8 +++++++- src/urlbar.h | 18 +++++++++++------- src/webview.cpp | 11 +++++------ src/webview.h | 15 ++++++++++----- 13 files changed, 78 insertions(+), 53 deletions(-) diff --git a/src/application.h b/src/application.h index 7a08eb1a..438a11e4 100644 --- a/src/application.h +++ b/src/application.h @@ -29,6 +29,7 @@ #include #include +// Forward Declarations class MainWindow; class WebView; class CookieJar; diff --git a/src/mainview.cpp b/src/mainview.cpp index cb84f56b..9e23ae2d 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -32,14 +32,18 @@ #include "webview.h" // KDE Includes +#include +#include +#include #include #include #include #include // Qt Includes +#include #include -#include +#include diff --git a/src/mainview.h b/src/mainview.h index 1f443a37..05a9bb16 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -22,24 +22,24 @@ #ifndef TABWIDGET_H #define TABWIDGET_H -// Local Includes -#include "tabbar.h" -#include "webview.h" // KDE Includes -#include -#include #include -#include -// Qt Includes -#include -#include -QT_BEGIN_NAMESPACE +// Forward Declarations +class WebView; +class TabBar; + +class KUrl; +class KAction; +class KMenu; + +class QWebFrame; class QCompleter; class QStackedWidget; -QT_END_NAMESPACE +class QLineEdit; +class QUrl; /** * TabWidget that contains WebViews and a stack widget of associated line edits. diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f28450fe..e24f4cf7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -41,6 +41,7 @@ #include "ui_passworddialog.h" // KDE Includes +#include #include #include #include @@ -55,14 +56,9 @@ // Qt Includes -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include MainWindow::MainWindow() diff --git a/src/mainwindow.h b/src/mainwindow.h index 4864f347..d620990e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -25,18 +25,18 @@ // Local Includes #include "findbar.h" #include "searchbar.h" +#include "bookmarks.h" +#include "mainview.h" // KDE Includes -#include #include #include -#include #include -#include +#include #include -class BookmarksProvider; -class MainView; +// Forward Declarations +class KUrl; class QWebFrame; class WebView; @@ -114,11 +114,12 @@ private: FindBar *m_findBar; KMenu *m_historyBackMenu; KMenu *m_windowMenu; - BookmarksProvider *m_bookmarksProvider; QAction *m_stopReload; QString m_lastSearch; - MainView *m_view; QString m_homePage; + + MainView *m_view; + BookmarksProvider *m_bookmarksProvider; }; #endif // MAINWINDOW_H diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h index 7d683967..987e33f4 100644 --- a/src/networkaccessmanager.h +++ b/src/networkaccessmanager.h @@ -21,7 +21,9 @@ #ifndef NETWORKACCESSMANAGER_H #define NETWORKACCESSMANAGER_H -#include + +#include + class NetworkAccessManager : public QNetworkAccessManager { diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 2f03e93a..1145d36e 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -26,8 +26,14 @@ #include "mainwindow.h" // KDE Includes +#include #include +// Qt Includes +#include +#include + + SearchBar::SearchBar(QWidget *parent) : KLineEdit(parent) { diff --git a/src/searchbar.h b/src/searchbar.h index 19c90a15..66319e60 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -23,12 +23,13 @@ // KDE Includes #include -#include -// Qt Includes -#include +// Forward Declarations +class KUrl; +class QFocusEvent; -/* + +/** * This class defines an internet search bar. */ class SearchBar : public KLineEdit diff --git a/src/settings.h b/src/settings.h index 109e3111..02322d4c 100644 --- a/src/settings.h +++ b/src/settings.h @@ -24,8 +24,8 @@ // KDE Includes #include -// Qt Includes -#include +// Forward Declarations +class QWidget; class Private; diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 3940d040..75f436be 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -17,12 +17,18 @@  *  * ============================================================ */ -// Local Includes +// Self Includes #include "urlbar.h" #include "urlbar.moc" +// Local Includes #include "application.h" #include "mainwindow.h" +#include "webview.h" + +// Qt Includes +#include +#include UrlBar::UrlBar(QWidget *parent) diff --git a/src/urlbar.h b/src/urlbar.h index c77f3b77..dfb59bcf 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -20,14 +20,18 @@ #ifndef URLBAR_H #define URLBAR_H -// Local Includes -#include "webview.h" // KDE Includes #include -// Qt Includes -#include +// Forward Declarations +class WebView; + +class QWidget; +class QLineEdit; +class QUrl; +class QLinearGradient; +class QColor; class UrlBar : public KHistoryComboBox @@ -51,9 +55,9 @@ protected: private: QLinearGradient generateGradient(const QColor &color) const; - WebView* m_webView; - QLineEdit* m_lineEdit; - QColor m_defaultBaseColor; + WebView* m_webView; + QLineEdit* m_lineEdit; + QColor m_defaultBaseColor; }; #endif diff --git a/src/webview.cpp b/src/webview.cpp index 0c2e0b6e..cf4d2398 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -18,7 +18,7 @@  *  * ============================================================ */ -// Local Includes +// Self Includes #include "webview.h" #include "webview.moc" @@ -34,17 +34,16 @@ // KDE Includes #include +#include #include // Qt Includes -#include -#include -#include -#include -// --- +#include +#include #include #include + WebPage::WebPage(QObject *parent) : QWebPage(parent) , m_keyboardModifiers(Qt::NoModifier) diff --git a/src/webview.h b/src/webview.h index 6892fbd4..b3d6ca1b 100644 --- a/src/webview.h +++ b/src/webview.h @@ -21,19 +21,21 @@ #ifndef WEBVIEW_H #define WEBVIEW_H +// KDE Includes #include -#include +// Qt Includes +#include + +// Forward Declarations +class MainWindow; -QT_BEGIN_NAMESPACE +class QWebFrame; class QAuthenticator; class QMouseEvent; class QNetworkProxy; class QNetworkReply; class QSslError; -QT_END_NAMESPACE - -class MainWindow; class WebPage : public QWebPage @@ -68,6 +70,9 @@ private: // --------------------------------------------------------------------------------------------------------------------------------------- +// Qt Includes +#include + class WebView : public QWebView { -- cgit v1.2.1 From bce15c7583913a7fc95b0206c5a093ac1bc3c55a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 11 Mar 2009 23:59:18 +0100 Subject: Solved Bookmark Position problem. Updated TODO. --- TODO | 8 ++++---- doc/index.docbook | 2 +- src/rekonqui.rc | 20 +++++++++++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/TODO b/TODO index 93ae6959..ada53236 100644 --- a/TODO +++ b/TODO @@ -15,11 +15,11 @@ To 0.0.4 1. check the lines above... 2. Improve docs -3. Let rekonq be a Singleton app. (And work well..) +DONE. Let rekonq be a Singleton app. (And work well..) 4. fix bookmarks toolbar POSITION 5. fix bookmarks action menu (in toolbar) -6. fix load at startup -7. fix FONTS problems between webkit && KDE settings (at least, here..) -8. enable flash support !! +DONE. fix load at startup +DONE. fix FONTS problems between webkit && KDE settings (at least, here..) +DONE. enable flash support !! + ------------------------ \ No newline at end of file diff --git a/doc/index.docbook b/doc/index.docbook index 2141c177..32fcb41e 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -30,7 +30,7 @@ &FDLNotice; 2008-11-16 -0.0.3 +0.0.4 diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 0e372e82..332e04fe 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,6 +1,9 @@ - - + + + + + &File @@ -19,6 +22,7 @@ + &Edit @@ -32,6 +36,7 @@ + &View @@ -43,23 +48,27 @@ + + + + -Main Toolbar +Main Toolbar @@ -67,7 +76,8 @@ - + -- cgit v1.2.1 From fe6a78a82803cf8be20eb0effc645ca1c4602b78 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 12 Mar 2009 00:01:49 +0100 Subject: upgrading ui to 4.5.0 --- TODO | 2 +- src/cookies.ui | 54 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/TODO b/TODO index ada53236..4df6b710 100644 --- a/TODO +++ b/TODO @@ -16,7 +16,7 @@ To 0.0.4 1. check the lines above... 2. Improve docs DONE. Let rekonq be a Singleton app. (And work well..) -4. fix bookmarks toolbar POSITION +DONE. fix bookmarks toolbar POSITION 5. fix bookmarks action menu (in toolbar) DONE. fix load at startup DONE. fix FONTS problems between webkit && KDE settings (at least, here..) diff --git a/src/cookies.ui b/src/cookies.ui index 384b31b0..49ad3a96 100644 --- a/src/cookies.ui +++ b/src/cookies.ui @@ -1,7 +1,8 @@ - + + CookiesDialog - - + + 0 0 @@ -9,16 +10,16 @@ 370 - + Cookies - - + + - + Qt::Horizontal - + 252 20 @@ -26,34 +27,34 @@ - - + + - - + + - - + + - - + + &Remove - - + + Remove &All Cookies - + Qt::Horizontal - + 40 20 @@ -62,8 +63,8 @@ - - + + QDialogButtonBox::Ok @@ -73,6 +74,11 @@ + + KLineEdit + QLineEdit +
    klineedit.h
    +
    EditTableView QTableView @@ -87,11 +93,11 @@ CookiesDialog accept() - + 472 329 - + 461 356 -- cgit v1.2.1 From 33af8415b29e428d926bb6e61f77e7faf91c4ff6 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 12 Mar 2009 00:53:37 +0100 Subject: Solved initial size problem! --- src/mainwindow.cpp | 12 ++++++++---- src/mainwindow.h | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e24f4cf7..1c515218 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -86,10 +86,6 @@ MainWindow::MainWindow() setCentralWidget(centralWidget); // setting size policies - QRect desktopRect = QApplication::desktop()->screenGeometry(); - QSize size = desktopRect.size() * 0.8; - setMinimumSize( size ); - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); // connect signals and slots @@ -154,6 +150,14 @@ MainWindow::~MainWindow() } +QSize MainWindow::sizeHint() const +{ + QRect desktopRect = QApplication::desktop()->screenGeometry(); + QSize size = desktopRect.size() * 0.8; + return size; +} + + void MainWindow::setupActions() { KAction *a; diff --git a/src/mainwindow.h b/src/mainwindow.h index d620990e..0082a2c0 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -57,6 +57,7 @@ public: static KUrl guessUrlFromString(const QString &url); MainView *tabWidget() const; WebView *currentTab() const; + virtual QSize sizeHint() const; private: void setupActions(); -- cgit v1.2.1 From a82439eec3599ac3d07516bee77713deb599299f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 12 Mar 2009 01:05:59 +0100 Subject: Added some warning --- src/webview.cpp | 15 ++++++++++++++- src/webview.h | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/webview.cpp b/src/webview.cpp index cf4d2398..b9af551d 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -55,6 +55,12 @@ WebPage::WebPage(QObject *parent) } +WebPage::~WebPage() +{ + +} + + MainWindow *WebPage::mainWindow() { QObject *w = this->parent(); @@ -70,6 +76,8 @@ MainWindow *WebPage::mainWindow() bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { + kWarning() << "Accepting Navigation Request.."; + // ctrl open in new tab and select // ctrl-alt open in new window if ( type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier @@ -87,6 +95,11 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r m_loadingUrl = request.url(); emit loadingUrl(m_loadingUrl); } + else + { + kWarning() << "NO Main Frame.."; + kWarning() << "Frame : " << frame->frameName(); + } return QWebPage::acceptNavigationRequest(frame, request, type); } @@ -177,7 +190,7 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) } -// ------------------------------------------------------------------------------------------------------------------------------------------------------ +// ----------------------------------------------------------------------------------------------------------------- WebView::WebView(QWidget* parent) diff --git a/src/webview.h b/src/webview.h index b3d6ca1b..f2e8d7dc 100644 --- a/src/webview.h +++ b/src/webview.h @@ -47,6 +47,8 @@ signals: public: WebPage(QObject *parent = 0); + ~WebPage(); + MainWindow *mainWindow(); protected: @@ -100,7 +102,7 @@ protected: void wheelEvent(QWheelEvent *event); /** - * FIlters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed() + * Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed() * to make switch tab */ void keyPressEvent(QKeyEvent *event); -- cgit v1.2.1 From 84a93ab8a47c8e4546ae658b5400623cdccfe237 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 16 Mar 2009 15:45:45 +0100 Subject: updated rekonq site fixed tab actions.. really near rekonq 0.0.4! Perhaps this night!! --- CMakeLists.txt | 7 ++++--- rekonq.SlackBuild | 2 +- src/main.cpp | 2 +- src/mainview.cpp | 4 ++-- src/tabbar.cpp | 61 ++++++++++++++++++------------------------------------- src/tabbar.h | 10 +++++---- 6 files changed, 34 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eea4c3e4..bb256387 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ PROJECT( rekonq ) # =============================================================================================== # Informations to update before to release this package. -# rekonq version +# rekonq info SET(REKONQ_MAJOR_VERSION "0") SET(REKONQ_MINOR_VERSION "0") SET(REKONQ_PATCH_VERSION "4") @@ -15,6 +15,8 @@ SET(REKONQ_VERSION_STR "${REKONQ_MAJOR_VERSION}.${REKONQ_MINOR_VERSION}.${REKONQ_PATCH_VERSION}" ) +SET(REKONQ_SITE "http://rekonq.sourceforge.net") + # ================================================================================================= # minimum cmake required @@ -37,8 +39,7 @@ INCLUDE(MacroLibrary) MESSAGE(STATUS "") MESSAGE(STATUS "----------------------------------------------------------------------------------") -MESSAGE(STATUS " rekonq ${REKONQ_VERSION_STR} dependencies results ") -MESSAGE(STATUS "") +MESSAGE(STATUS " rekonq ${REKONQ_VERSION_STR} dependencies results <${REKONQ_SITE}>") # Require shared libraries results. diff --git a/rekonq.SlackBuild b/rekonq.SlackBuild index 000314ee..1ea4877a 100644 --- a/rekonq.SlackBuild +++ b/rekonq.SlackBuild @@ -4,7 +4,7 @@ # Written by Andrea Diamantini - adjam7_AT_gmail_DOT_com NAME=rekonq -VERSION=0.0.3 +VERSION=0.0.4 ARCH=${ARCH:-i486} BUILD=1ad diff --git a/src/main.cpp b/src/main.cpp index a97bb0d5..5315a1d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char **argv) KAboutData::License_GPL, ki18n("(C) 2008 Andrea Diamantini"), KLocalizedString(), - "http://rekonq.adjam.org", + "http://rekonq.soourceforge.net", "adjam7@gmail.com" ); diff --git a/src/mainview.cpp b/src/mainview.cpp index 9e23ae2d..d7e07e14 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -39,6 +39,7 @@ #include #include #include +#include // Qt Includes #include @@ -55,7 +56,7 @@ MainView::MainView(QWidget *parent) , m_lineEdits(new QStackedWidget(this)) , m_tabBar(new TabBar(this)) { - setElideMode(Qt::ElideRight); + setTabBar(m_tabBar); connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); @@ -64,7 +65,6 @@ MainView::MainView(QWidget *parent) connect(m_tabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int))); connect(m_tabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs())); connect(m_tabBar, SIGNAL(tabMoveRequested(int, int)), this, SLOT(moveTab(int, int))); - setTabBar(m_tabBar); // Recently Closed Tab Action m_recentlyClosedTabsMenu = new KMenu(this); diff --git a/src/tabbar.cpp b/src/tabbar.cpp index c28a390c..8f648f28 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -34,6 +34,7 @@ #include #include #include +#include // Qt Includes #include @@ -48,18 +49,19 @@ TabBar::TabBar(QWidget *parent) setAcceptDrops(true); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); - QString alt = QLatin1String("Alt+%1"); - for (int i = 1; i <= 10; ++i) - { - int key = i; - if (key == 10) - { - key = 0; - } - QShortcut *shortCut = new QShortcut(alt.arg(key), this); - m_tabShortcuts.append(shortCut); - connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); - } +// FIXME: not sure we need this.. +// QString alt = QLatin1String("Alt+%1"); +// for (int i = 1; i <= 10; ++i) +// { +// int key = i; +// if (key == 10) +// { +// key = 0; +// } +// QShortcut *shortCut = new QShortcut(alt.arg(key), this); +// m_tabShortcuts.append(shortCut); +// connect(shortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); +// } } @@ -88,21 +90,14 @@ void TabBar::contextMenuRequested(const QPoint &position) int index = tabAt(position); if (-1 != index) { - KAction *action = (KAction * ) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); - action->setData(index); + m_actualIndex = index; + KAction *action = (KAction * ) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); menu.addSeparator(); - action = (KAction * ) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); - action->setData(index); - action = (KAction * ) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); - action->setData(index); - menu.addSeparator(); - action = (KAction * ) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); - action->setData(index); } else { @@ -115,31 +110,19 @@ void TabBar::contextMenuRequested(const QPoint &position) void TabBar::cloneTab() { - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit cloneTab(index); - } + emit cloneTab(m_actualIndex); } void TabBar::closeTab() { - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit closeTab(index); - } + emit closeTab(m_actualIndex); } void TabBar::closeOtherTabs() { - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit closeOtherTabs(index); - } + emit closeOtherTabs(m_actualIndex); } @@ -199,10 +182,6 @@ void TabBar::dropEvent(QDropEvent *event) void TabBar::reloadTab() { - if (KAction *action = qobject_cast(sender())) - { - int index = action->data().toInt(); - emit reloadTab(index); - } + emit reloadTab(m_actualIndex); } diff --git a/src/tabbar.h b/src/tabbar.h index 0692fcd6..0dbdd004 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -36,6 +36,11 @@ class TabBar : public KTabBar { Q_OBJECT + +public: + TabBar(QWidget *parent = 0); + ~TabBar(); + signals: void newTab(); void cloneTab(int index); @@ -45,10 +50,6 @@ signals: void reloadAllTabs(); void tabMoveRequested(int fromIndex, int toIndex); -public: - TabBar(QWidget *parent = 0); - ~TabBar(); - protected: void mousePressEvent(QMouseEvent* event); void mouseMoveEvent(QMouseEvent* event); @@ -69,6 +70,7 @@ private: QPoint m_dragStartPos; int m_dragCurrentIndex; + int m_actualIndex; // the index in which we are seeing a Context menu }; #endif -- cgit v1.2.1 From 1f9c6c5e02f2b3689195bd3523d8378c4e9153bd Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 16 Mar 2009 16:42:14 +0100 Subject: Fixing No Scheme Loading Url. Try 1.. --- src/webview.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/webview.cpp b/src/webview.cpp index b9af551d..b8db6825 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -274,10 +274,22 @@ void WebView::loadFinished() } +// FIXME: load http by default!! void WebView::loadUrl(const KUrl &url) { m_initialUrl = url; - load(url); + + if( m_initialUrl.isRelative() ) + { + kWarning() << "1: " << m_initialUrl.url(); + QString fn = m_initialUrl.url( KUrl::RemoveTrailingSlash ); + kWarning() << "2: " << fn; + m_initialUrl.setUrl( "//" + fn ); + m_initialUrl.setScheme("http"); + kWarning() << "3: " << m_initialUrl.url(); + } + + load(m_initialUrl); } -- cgit v1.2.1 From 4bb412bc31cb28a5cafeb2403ebd5322e4e1e787 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 17 Mar 2009 01:54:55 +0100 Subject: 0.0.4 Changes --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 473a1d76..1c830037 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +0.0.4 +- Rekonq Singleton app +- With Qt 4.5, preliminary flash support +- Fixed tabbar actions +- Fixed System Font Loading +- improved bookmarks system + 0.0.3 - ~80% ported to KDE4 - use KConfigXT -- cgit v1.2.1 From 77a4e79d9969e42cfd6639de1d47207c58cdd1db Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 17 Mar 2009 15:53:42 +0100 Subject: Fixed rekonq slack-desc && slackbuild --- rekonq.SlackBuild | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rekonq.SlackBuild b/rekonq.SlackBuild index 1ea4877a..2de6ceae 100644 --- a/rekonq.SlackBuild +++ b/rekonq.SlackBuild @@ -62,8 +62,7 @@ cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild # Copy the slack-desc (and a custom doinst.sh if necessary) into ./install mkdir -p $PKG/install -cat $CWD/slack-desc > $PKG/install/slack-desc -cat $CWD/doinst.sh > $PKG/install/doinst.sh +cat $CWD/data/slack-desc > $PKG/install/slack-desc # Make the package; # If package symlinks need to be created during install *before* -- cgit v1.2.1 From 5c64bca9fa0ef91aa062294a8d89aa64df6e82b4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 17 Mar 2009 15:54:19 +0100 Subject: Fixed rekonq site URL --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 5315a1d2..48992561 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char **argv) KAboutData::License_GPL, ki18n("(C) 2008 Andrea Diamantini"), KLocalizedString(), - "http://rekonq.soourceforge.net", + "http://rekonq.sourceforge.net", "adjam7@gmail.com" ); -- cgit v1.2.1 From 11f03d149e9aecbe216400b754456372fc80d1bb Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 19 Mar 2009 01:15:07 +0100 Subject: Fixed slackbuild with right slack-desc --- data/slack-desc | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 data/slack-desc diff --git a/data/slack-desc b/data/slack-desc new file mode 100644 index 00000000..3136b228 --- /dev/null +++ b/data/slack-desc @@ -0,0 +1,12 @@ + |-------------------------------------------------------------------| +rekonq: rekonq (Webkit KDE Browser) +rekonq: +rekonq: rekonq is a lightweight KDE browser based on webkit +rekonq: +rekonq: +rekonq: +rekonq: +rekonq: +rekonq: +rekonq: +rekonq: -- cgit v1.2.1 From bf4afe9b0ebc2d3a04d4e1cd46c46f773d4f1b41 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Thu, 19 Mar 2009 01:15:37 +0100 Subject: Fixed notfound.html Thanks, Eelko! --- htmls/notfound.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htmls/notfound.html b/htmls/notfound.html index 6ffbc9f3..fdfb80bf 100644 --- a/htmls/notfound.html +++ b/htmls/notfound.html @@ -1,7 +1,8 @@ - + + %1 - - - -
    - Not found -

    %3

    -

    When connecting to: %4.

    -
      -
    • Check the address for errors such as ww.kde.org - instead of www.kde.org
    • -
    • If the address is correct, try to check the network - connection.
    • -
    • If your computer or network is protected by a firewall or - proxy, make sure that rekonq is permitted to access - the network.
    • -
    • Of course, if rekonq doesn't work properly, you can always - say it's a programmer error ;)
    • -
    -

    -
    - - -- cgit v1.2.1 From 940f1c852e906e5b314c314d3e821e58c90b3148 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 25 Mar 2009 01:25:07 +0100 Subject: Fixed CMakelists --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb256387..14957a20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ PROJECT( rekonq ) # rekonq info SET(REKONQ_MAJOR_VERSION "0") SET(REKONQ_MINOR_VERSION "0") -SET(REKONQ_PATCH_VERSION "4") +SET(REKONQ_PATCH_VERSION "5") SET(REKONQ_VERSION_STR "${REKONQ_MAJOR_VERSION}.${REKONQ_MINOR_VERSION}.${REKONQ_PATCH_VERSION}" @@ -89,7 +89,6 @@ IF(REKONQ_CAN_BE_COMPILED) ADD_SUBDIRECTORY( src ) ADD_SUBDIRECTORY( icons ) ADD_SUBDIRECTORY( data ) - ADD_SUBDIRECTORY( htmls ) # ADD_SUBDIRECTORY( doc ) ENDIF(REKONQ_CAN_BE_COMPILED) -- cgit v1.2.1 From b8a008392dc11622224d6ab192febfe9fd5bc80f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 25 Mar 2009 01:25:23 +0100 Subject: pedantic.. --- data/notfound.html | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 data/notfound.html diff --git a/data/notfound.html b/data/notfound.html new file mode 100644 index 00000000..09039eb1 --- /dev/null +++ b/data/notfound.html @@ -0,0 +1,66 @@ + + + +%1 + + + +
    + Not found +

    %3

    +

    When connecting to: %4.

    +
      +
    • Check the address for errors such as ww.kde.org + instead of www.kde.org
    • +
    • If the address is correct, try to check the network + connection.
    • +
    • If your computer or network is protected by a firewall or + proxy, make sure that rekonq is permitted to access + the network.
    • +
    • Of course, if rekonq doesn't work properly, you can always + say it's a programmer error ;)
    • +
    +

    +
    + + -- cgit v1.2.1 From f922f33d3a73ae996224653df7fcdcd1783a1245 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 25 Mar 2009 01:46:28 +0100 Subject: created rekonq.pot file --- po/rekonq.pot | 738 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 738 insertions(+) create mode 100644 po/rekonq.pot diff --git a/po/rekonq.pot b/po/rekonq.pot new file mode 100644 index 00000000..9ce50dd8 --- /dev/null +++ b/po/rekonq.pot @@ -0,0 +1,738 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" +"group_id=252277&atid=1126949\n" +"POT-Creation-Date: 2009-03-25 01:44+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: cookiejar.cpp:469 cookiejar.cpp:638 +msgid "Website" +msgstr "" + +#: cookiejar.cpp:471 +msgid "Name" +msgstr "" + +#: cookiejar.cpp:473 +msgid "Path" +msgstr "" + +#: cookiejar.cpp:475 +msgid "Secure" +msgstr "" + +#: cookiejar.cpp:477 +msgid "Expires" +msgstr "" + +#: cookiejar.cpp:479 +msgid "Contents" +msgstr "" + +#: cookiejar.cpp:640 +msgid "Status" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:77 +#. i18n: ectx: property (text), widget (QPushButton, allowButton) +#: cookiejar.cpp:661 rc.cpp:27 +msgid "Allow" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:57 +#. i18n: ectx: property (text), widget (QPushButton, blockButton) +#: cookiejar.cpp:670 rc.cpp:21 +msgid "Block" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:67 +#. i18n: ectx: property (text), widget (QPushButton, allowForSessionButton) +#: cookiejar.cpp:679 rc.cpp:24 +msgid "Allow For Session" +msgstr "" + +#: history.cpp:416 +msgid "Title" +msgstr "" + +#: history.cpp:417 +msgid "Address" +msgstr "" + +#: history.cpp:657 +msgid "Show All History" +msgstr "" + +#: history.cpp:661 +msgid "Clear History" +msgstr "" + +#: history.cpp:739 +msgid "Open" +msgstr "" + +#: history.cpp:741 +msgid "Copy" +msgstr "" + +#: history.cpp:743 +msgid "Delete" +msgstr "" + +#: history.cpp:1111 +msgid "Earlier Today" +msgstr "" + +#: history.cpp:1115 +msgid " items" +msgstr "" + +#: main.cpp:29 +msgid "KDE Browser Webkit Based" +msgstr "" + +#: main.cpp:39 +msgid "rekonq" +msgstr "" + +#: main.cpp:43 +msgid "(C) 2008 Andrea Diamantini" +msgstr "" + +#: main.cpp:49 +msgid "Andrea Diamantini" +msgstr "" + +#: main.cpp:57 +msgid "Location to open" +msgstr "" + +#: mainview.cpp:76 +msgid "Recently Closed Tabs" +msgstr "" + +#: mainview.cpp:368 mainview.cpp:392 +msgid "(Untitled)" +msgstr "" + +#: mainview.cpp:488 +msgid "" +"You have modified this page and when closing it you would lose the " +"modification.\n" +"Do you really want to close this page?\n" +msgstr "" + +#: mainview.cpp:490 +msgid "Do you really want to close this page?" +msgstr "" + +#: mainwindow.cpp:114 +msgid "B&ookmarks" +msgstr "" + +#: mainwindow.cpp:191 +msgid "&Stop" +msgstr "" + +#: mainwindow.cpp:197 +msgid "reload" +msgstr "" + +#: mainwindow.cpp:201 +msgid "Open Location" +msgstr "" + +#: mainwindow.cpp:205 +msgid "Private &Browsing..." +msgstr "" + +#: mainwindow.cpp:207 +msgid "private browsing" +msgstr "" + +#: mainwindow.cpp:210 +msgid "&Enlarge Font" +msgstr "" + +#: mainwindow.cpp:215 +msgid "&Normal Font" +msgstr "" + +#: mainwindow.cpp:220 +msgid "&Shrink Font" +msgstr "" + +#: mainwindow.cpp:225 +msgid "Page S&ource" +msgstr "" + +#: mainwindow.cpp:229 +msgid "Enable Web &Inspector" +msgstr "" + +#: mainwindow.cpp:235 +msgid "Back" +msgstr "" + +#: mainwindow.cpp:243 +msgid "Forward" +msgstr "" + +#: mainwindow.cpp:248 tabbar.cpp:101 +msgid "New &Tab" +msgstr "" + +#: mainwindow.cpp:253 tabbar.cpp:109 +msgid "&Close Tab" +msgstr "" + +#: mainwindow.cpp:258 +msgid "Show Next Tab" +msgstr "" + +#: mainwindow.cpp:263 +msgid "Show Previous Tab" +msgstr "" + +#: mainwindow.cpp:293 +msgid "&History" +msgstr "" + +#: mainwindow.cpp:476 +msgid "Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)" +msgstr "" + +#: mainwindow.cpp:478 +msgid "Open Web Resource" +msgstr "" + +#: mainwindow.cpp:510 +msgid "Print Document" +msgstr "" + +#: mainwindow.cpp:523 +msgid "Are you sure you want to turn on private browsing?" +msgstr "" + +#: mainwindow.cpp:524 +msgid "" +"

    When private browsing in turned on, webpages are not added to " +"the history, items are automatically removed from the Downloads window, new " +"cookies are not stored, current cookies can't be accessed, site icons wont " +"be stored, session wont be saved, and searches are not addded to the pop-up " +"menu in the Google search box. Until you close the window, you can still " +"click the Back and Forward buttons to return to the webpages you have opened." +msgstr "" + +#: mainwindow.cpp:590 mainwindow.cpp:601 +msgid " not found." +msgstr "" + +#: mainwindow.cpp:644 +msgid "Page Source of " +msgstr "" + +#: mainwindow.cpp:663 +msgid "" +"The web inspector will only work correctly for pages that were loaded after " +"enabling.\n" +"Do you want to reload all pages?" +msgstr "" + +#: mainwindow.cpp:665 +msgid "Web Inspector" +msgstr "" + +#: mainwindow.cpp:709 +msgid "Stop loading the current page" +msgstr "" + +#: mainwindow.cpp:710 +msgid "Stop" +msgstr "" + +#: mainwindow.cpp:717 +msgid "Reload the current page" +msgstr "" + +#: mainwindow.cpp:718 +msgid "Reload" +msgstr "" + +#: networkaccessmanager.cpp:103 +msgid "Enter username and password for " +msgstr "" + +#: networkaccessmanager.cpp:104 +msgid " at " +msgstr "" + +#: networkaccessmanager.cpp:128 +msgid "Connect to proxy " +msgstr "" + +#: networkaccessmanager.cpp:128 +msgid " using:" +msgstr "" + +#: networkaccessmanager.cpp:148 +msgid "" +"SSL Errors:\n" +"\n" +msgstr "" + +#: searchbar.cpp:55 +msgid "Search.." +msgstr "" + +#. i18n: file: settings_general.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, general) +#: settings.cpp:78 rc.cpp:111 +msgid "General" +msgstr "" + +#. i18n: file: settings_fonts.ui:20 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox) +#: settings.cpp:84 rc.cpp:96 +msgid "Fonts" +msgstr "" + +#. i18n: file: settings_privacy.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, privacy) +#: settings.cpp:90 rc.cpp:141 +msgid "Privacy" +msgstr "" + +#. i18n: file: settings_proxy.ui:13 +#. i18n: ectx: property (windowTitle), widget (QWidget, proxy) +#: settings.cpp:96 rc.cpp:201 +msgid "Proxy" +msgstr "" + +#: settings.cpp:109 +msgid "rekonfig.." +msgstr "" + +#: tabbar.cpp:107 +msgid "Clone Tab" +msgstr "" + +#: tabbar.cpp:110 +msgid "Close &Other Tabs" +msgstr "" + +#: tabbar.cpp:112 +msgid "Reload Tab" +msgstr "" + +#: tabbar.cpp:118 +msgid "Reload All Tabs" +msgstr "" + +#: webview.cpp:162 +msgid "Error loading page: " +msgstr "" + +#: webview.cpp:220 +msgid "Open in New Tab" +msgstr "" + +#. i18n: file: cookies.ui:14 +#. i18n: ectx: property (windowTitle), widget (QDialog, CookiesDialog) +#. i18n: file: settings_privacy.ui:73 +#. i18n: ectx: property (title), widget (QGroupBox, cookiesGroupBox) +#: rc.cpp:3 rc.cpp:168 +msgid "Cookies" +msgstr "" + +#. i18n: file: cookies.ui:41 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#. i18n: file: cookiesexceptions.ui:114 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#. i18n: file: history.ui:40 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#: rc.cpp:6 rc.cpp:33 rc.cpp:42 +msgid "&Remove" +msgstr "" + +#. i18n: file: cookies.ui:48 +#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) +#: rc.cpp:9 +msgid "Remove &All Cookies" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, CookiesExceptionsDialog) +#: rc.cpp:12 +msgid "Cookie Exceptions" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:19 +#. i18n: ectx: property (title), widget (QGroupBox, newExceptionGroupBox) +#: rc.cpp:15 +msgid "New Exception" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:27 +#. i18n: ectx: property (text), widget (QLabel, label) +#: rc.cpp:18 +msgid "Domain:" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:89 +#. i18n: ectx: property (title), widget (QGroupBox, ExceptionsGroupBox) +#: rc.cpp:30 +msgid "Exceptions" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:121 +#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) +#. i18n: file: history.ui:47 +#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) +#: rc.cpp:36 rc.cpp:45 +msgid "Remove &All" +msgstr "" + +#. i18n: file: history.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, HistoryDialog) +#. i18n: file: settings_privacy.ui:20 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) +#: rc.cpp:39 rc.cpp:144 +msgid "History" +msgstr "" + +#. i18n: file: passworddialog.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, PasswordDialog) +#: rc.cpp:48 +msgid "Authentication Required" +msgstr "" + +#. i18n: file: passworddialog.ui:21 +#. i18n: ectx: property (text), widget (QLabel, iconLabel) +#: rc.cpp:51 +msgid "DUMMY ICON" +msgstr "" + +#. i18n: file: passworddialog.ui:34 +#. i18n: ectx: property (text), widget (QLabel, introLabel) +#: rc.cpp:54 +msgid "INTRO TEXT DUMMY" +msgstr "" + +#. i18n: file: passworddialog.ui:43 +#. i18n: ectx: property (text), widget (QLabel, label) +#. i18n: file: proxy.ui:36 +#. i18n: ectx: property (text), widget (QLabel, usernameLabel) +#: rc.cpp:57 rc.cpp:72 +msgid "Username:" +msgstr "" + +#. i18n: file: passworddialog.ui:53 +#. i18n: ectx: property (text), widget (QLabel, lblPassword) +#. i18n: file: proxy.ui:46 +#. i18n: ectx: property (text), widget (QLabel, passwordLabel) +#. i18n: file: settings_proxy.ui:115 +#. i18n: ectx: property (text), widget (QLabel, label_13) +#: rc.cpp:60 rc.cpp:75 rc.cpp:228 +msgid "Password:" +msgstr "" + +#. i18n: file: proxy.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, ProxyDialog) +#: rc.cpp:63 +msgid "Proxy Authentication" +msgstr "" + +#. i18n: file: proxy.ui:19 +#. i18n: ectx: property (text), widget (QLabel, iconLabel) +#: rc.cpp:66 +msgid "ICON" +msgstr "" + +#. i18n: file: proxy.ui:26 +#. i18n: ectx: property (text), widget (QLabel, introLabel) +#: rc.cpp:69 +msgid "Connect to proxy" +msgstr "" + +#. i18n: file: rekonqui.rc:8 +#. i18n: ectx: Menu (file) +#: rc.cpp:78 +msgid "&File" +msgstr "" + +#. i18n: file: rekonqui.rc:27 +#. i18n: ectx: Menu (edit) +#: rc.cpp:81 +msgid "&Edit" +msgstr "" + +#. i18n: file: rekonqui.rc:41 +#. i18n: ectx: Menu (view) +#: rc.cpp:84 +msgid "&View" +msgstr "" + +#. i18n: file: rekonqui.rc:71 +#. i18n: ectx: ToolBar (mainToolBar) +#: rc.cpp:87 +msgid "Main Toolbar" +msgstr "" + +#. i18n: file: rekonqui.rc:80 +#. i18n: ectx: ToolBar (bookmarksToolBar) +#: rc.cpp:90 +msgid "Bookmark Toolbar" +msgstr "" + +#. i18n: file: settings_fonts.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, fonts) +#. i18n: file: settings_general.ui:86 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox_3) +#: rc.cpp:93 rc.cpp:126 +msgid "Appearance" +msgstr "" + +#. i18n: file: settings_fonts.ui:28 +#. i18n: ectx: property (text), widget (QLabel, label) +#: rc.cpp:99 +msgid "Standard Font" +msgstr "" + +#. i18n: file: settings_fonts.ui:35 +#. i18n: ectx: property (text), widget (QLabel, label_2) +#: rc.cpp:102 +msgid "Fixed Font" +msgstr "" + +#. i18n: file: settings_fonts.ui:53 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) +#: rc.cpp:105 +msgid "Dimension" +msgstr "" + +#. i18n: file: settings_fonts.ui:61 +#. i18n: ectx: property (text), widget (QLabel, label_3) +#: rc.cpp:108 +msgid "Font Size" +msgstr "" + +#. i18n: file: settings_general.ui:20 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox) +#: rc.cpp:114 +msgid "Places" +msgstr "" + +#. i18n: file: settings_general.ui:26 +#. i18n: ectx: property (text), widget (QLabel, label_3) +#: rc.cpp:117 +msgid "Home:" +msgstr "" + +#. i18n: file: settings_general.ui:48 +#. i18n: ectx: property (text), widget (QPushButton, setHomeToCurrentPageButton) +#: rc.cpp:120 +msgid "Set to current page" +msgstr "" + +#. i18n: file: settings_general.ui:73 +#. i18n: ectx: property (text), widget (QLabel, label_7) +#: rc.cpp:123 +msgid "Save downloads to:" +msgstr "" + +#. i18n: file: settings_general.ui:92 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_alwaysShowTabBar) +#: rc.cpp:129 +msgid "Always show TabBar" +msgstr "" + +#. i18n: file: settings_general.ui:102 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) +#: rc.cpp:132 +msgid "Web Content" +msgstr "" + +#. i18n: file: settings_general.ui:108 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_enablePlugins) +#: rc.cpp:135 +msgid "Enable Plugins" +msgstr "" + +#. i18n: file: settings_general.ui:118 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_enableJavascript) +#: rc.cpp:138 +msgid "Enable Javascript" +msgstr "" + +#. i18n: file: settings_privacy.ui:26 +#. i18n: ectx: property (text), widget (QLabel, label_4) +#: rc.cpp:147 +msgid "Remove history items:" +msgstr "" + +#. i18n: file: settings_privacy.ui:37 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:150 +msgid "After one day" +msgstr "" + +#. i18n: file: settings_privacy.ui:42 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:153 +msgid "After one week" +msgstr "" + +#. i18n: file: settings_privacy.ui:47 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:156 +msgid "After two weeks" +msgstr "" + +#. i18n: file: settings_privacy.ui:52 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:159 +msgid "After one month" +msgstr "" + +#. i18n: file: settings_privacy.ui:57 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:162 +msgid "After one year" +msgstr "" + +#. i18n: file: settings_privacy.ui:62 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:165 +msgid "Manually" +msgstr "" + +#. i18n: file: settings_privacy.ui:79 +#. i18n: ectx: property (text), widget (QLabel, label_2) +#: rc.cpp:171 +msgid "Accept Cookies:" +msgstr "" + +#. i18n: file: settings_privacy.ui:90 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) +#: rc.cpp:174 +msgid "Always" +msgstr "" + +#. i18n: file: settings_privacy.ui:95 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) +#: rc.cpp:177 +msgid "Never" +msgstr "" + +#. i18n: file: settings_privacy.ui:100 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) +#: rc.cpp:180 +msgid "Only from sites you navigate to" +msgstr "" + +#. i18n: file: settings_privacy.ui:108 +#. i18n: ectx: property (text), widget (QPushButton, exceptionsButton) +#: rc.cpp:183 +msgid "Exceptions..." +msgstr "" + +#. i18n: file: settings_privacy.ui:115 +#. i18n: ectx: property (text), widget (QLabel, label) +#: rc.cpp:186 +msgid "Keep until:" +msgstr "" + +#. i18n: file: settings_privacy.ui:126 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) +#: rc.cpp:189 +msgid "They expire" +msgstr "" + +#. i18n: file: settings_privacy.ui:131 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) +#: rc.cpp:192 +msgid "I exit the application" +msgstr "" + +#. i18n: file: settings_privacy.ui:136 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) +#: rc.cpp:195 +msgid "At most 90 days" +msgstr "" + +#. i18n: file: settings_privacy.ui:144 +#. i18n: ectx: property (text), widget (QPushButton, cookiesButton) +#: rc.cpp:198 +msgid "Cookies..." +msgstr "" + +#. i18n: file: settings_proxy.ui:19 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_isProxyEnabled) +#: rc.cpp:204 +msgid "enable proxy" +msgstr "" + +#. i18n: file: settings_proxy.ui:26 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox) +#: rc.cpp:207 +msgid "Proxy Settings" +msgstr "" + +#. i18n: file: settings_proxy.ui:32 +#. i18n: ectx: property (text), widget (QLabel, label_9) +#: rc.cpp:210 +msgid "Type:" +msgstr "" + +#. i18n: file: settings_proxy.ui:43 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_proxyType) +#: rc.cpp:213 +msgid "Socks5" +msgstr "" + +#. i18n: file: settings_proxy.ui:48 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_proxyType) +#: rc.cpp:216 +msgid "Http" +msgstr "" + +#. i18n: file: settings_proxy.ui:56 +#. i18n: ectx: property (text), widget (QLabel, label_10) +#: rc.cpp:219 +msgid "Host:" +msgstr "" + +#. i18n: file: settings_proxy.ui:69 +#. i18n: ectx: property (text), widget (QLabel, label_11) +#: rc.cpp:222 +msgid "Port:" +msgstr "" + +#. i18n: file: settings_proxy.ui:102 +#. i18n: ectx: property (text), widget (QLabel, label_12) +#: rc.cpp:225 +msgid "User Name:" +msgstr "" + +#: rc.cpp:229 +msgctxt "NAME OF TRANSLATORS" +msgid "Andrea Diamantini" +msgstr "" + +#: rc.cpp:230 +msgctxt "EMAIL OF TRANSLATORS" +msgid "adjam7@gmail.com" +msgstr "" -- cgit v1.2.1 From 3434cd81168e996b66ca6583d5b68cd19bf14c09 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 27 Mar 2009 03:14:47 +0100 Subject: Some fixes from avaddon-clone. Thank you --- src/mainview.cpp | 9 +++++---- src/tabbar.cpp | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mainview.cpp b/src/mainview.cpp index a1eed467..7238b966 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -91,8 +91,9 @@ MainView::~MainView() void MainView::showTabBar() { - bool always = ReKonfig::alwaysShowTabBar(); - if(always == true) + bool astb = ReKonfig::alwaysShowTabBar(); + + if(astb == true) { if( m_tabBar->isHidden() ) { @@ -593,7 +594,7 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) newTab(); return; } - QTabWidget::mouseDoubleClickEvent(event); + KTabWidget::mouseDoubleClickEvent(event); } @@ -603,7 +604,7 @@ void MainView::contextMenuEvent(QContextMenuEvent *event) m_tabBar->contextMenuRequested(event->pos()); return; } - QTabWidget::contextMenuEvent(event); + KTabWidget::contextMenuEvent(event); } diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 2e29fb0c..d00a95ce 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -53,7 +53,7 @@ TabBar::TabBar(QWidget *parent) QFont standardFont = KGlobalSettings::generalFont(); QString fontFamily = standardFont.family(); int dim = standardFont.pointSize(); - setFont( QFont(fontFamily, dim-2) ); + setFont( QFont(fontFamily, dim-1) ); } @@ -75,7 +75,7 @@ QSize TabBar::tabSizeHint (int index) const { w = s.width() / 3; } - int h = s.height() / 20; + int h = KTabBar::tabSizeHint(index).height(); QSize ts = QSize(w,h); return ts; -- cgit v1.2.1 From fbd78bee04e335314337c57c679dae2dd0820dae Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 27 Mar 2009 03:36:22 +0100 Subject: improved fullscreen --- TODO | 4 ++-- src/mainwindow.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index f14bb05c..ba905862 100644 --- a/TODO +++ b/TODO @@ -1,17 +1,17 @@ To 0.0.5 -DONE definitely fix fonts! +DONE(?) definitely fix fonts! - fix crash on example sites.. DONE tabbar: fixed dimension DONE tabbar: hide if just one DONE bookmarks tabbar update DONE loading right bookmark file DONE Added Google Suggestions -- improve "save as" - load just ONE site at start - loading right sites as "external browser" - provide translations DONE notfound.html shown if rekonq doesn't load connection - disable BACK button when history is NULL +DONE improve fullscreen To 0.0.4 - improve DOCUMENTATION diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4abfcd15..54516e78 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -630,6 +630,16 @@ void MainWindow::slotViewTextSmaller() // TODO improve this void MainWindow::slotViewFullScreen( bool makeFullScreen ) { + if ( makeFullScreen == true ) + { + menuBar()->hide(); + toolBar("mainToolBar")->hide(); + } + else + { + menuBar()->show(); + toolBar("mainToolBar")->show(); + } KToggleFullScreenAction::setFullScreen( this, makeFullScreen ); } -- cgit v1.2.1 From 473540ed565ce6c2f5767e29b956aad0dadf458d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 28 Mar 2009 15:46:46 +0100 Subject: Added QNetworkDiskCache. Thanks to Ben Meyer's Qt Blog post --- TODO | 12 ++++++++---- src/Messages.sh | 4 ---- src/history.cpp | 32 ++++++++++++++++++++++---------- src/mainwindow.cpp | 1 + src/networkaccessmanager.cpp | 12 ++++++++++++ 5 files changed, 43 insertions(+), 18 deletions(-) delete mode 100755 src/Messages.sh diff --git a/TODO b/TODO index ba905862..c9d47122 100644 --- a/TODO +++ b/TODO @@ -1,17 +1,21 @@ To 0.0.5 -DONE(?) definitely fix fonts! -- fix crash on example sites.. DONE tabbar: fixed dimension DONE tabbar: hide if just one DONE bookmarks tabbar update DONE loading right bookmark file DONE Added Google Suggestions +DONE notfound.html shown if rekonq doesn't load connection +DONE improve fullscreen +DONE QNetworkDiskCache +- QWebFrame +DONE(?) definitely fix fonts! +- fix crash on example sites.. - load just ONE site at start - loading right sites as "external browser" - provide translations -DONE notfound.html shown if rekonq doesn't load connection - disable BACK button when history is NULL -DONE improve fullscreen +- improve DOCUMENTATION + To 0.0.4 - improve DOCUMENTATION diff --git a/src/Messages.sh b/src/Messages.sh deleted file mode 100755 index 76d48b4b..00000000 --- a/src/Messages.sh +++ /dev/null @@ -1,4 +0,0 @@ -#! /usr/bin/env bash -$EXTRACTRC `find . -name \*.ui -o -name \*.rc -o -name \*.kcfg` >> rc.cpp -$XGETTEXT `find . -name \*.cpp` -o $podir/rekonq.pot - diff --git a/src/history.cpp b/src/history.cpp index 5023bfd3..5c545b10 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -177,7 +177,6 @@ void HistoryManager::addHistoryItem(const HistoryItem &item) } - void HistoryManager::updateHistoryItem(const KUrl &url, const QString &title) { for (int i = 0; i < m_history.count(); ++i) @@ -493,9 +492,11 @@ bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent) -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// ----------------------------------------------------------------------------------------------- + + +#define MOVEDROWS 10 -#define MOVEDROWS 15 /* Maps the first bunch of items of the source model to the root @@ -507,6 +508,7 @@ HistoryMenuModel::HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *paren setSourceModel(sourceModel); } + int HistoryMenuModel::bumpedRows() const { QModelIndex first = m_treeModel->index(0, 0); @@ -515,11 +517,13 @@ int HistoryMenuModel::bumpedRows() const return qMin(m_treeModel->rowCount(first), MOVEDROWS); } + int HistoryMenuModel::columnCount(const QModelIndex &parent) const { return m_treeModel->columnCount(mapToSource(parent)); } + int HistoryMenuModel::rowCount(const QModelIndex &parent) const { if (parent.column() > 0) @@ -546,6 +550,7 @@ int HistoryMenuModel::rowCount(const QModelIndex &parent) const return defaultCount; } + QModelIndex HistoryMenuModel::mapFromSource(const QModelIndex &sourceIndex) const { // currently not used or autotested @@ -554,6 +559,7 @@ QModelIndex HistoryMenuModel::mapFromSource(const QModelIndex &sourceIndex) cons return createIndex(sourceIndex.row(), sourceIndex.column(), sr); } + QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const { if (!proxyIndex.isValid()) @@ -573,6 +579,7 @@ QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const return treeIndex; } + QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 @@ -595,6 +602,7 @@ QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &pare return createIndex(row, column, historyRow); } + QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const { int offset = index.internalId(); @@ -613,7 +621,8 @@ QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const } -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------------------- + HistoryMenu::HistoryMenu(QWidget *parent) : ModelMenu(parent) @@ -680,7 +689,8 @@ void HistoryMenu::setInitialActions(QList actions) } -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// -------------------------------------------------------------------------------------------------------------- + TreeProxyModel::TreeProxyModel(QObject *parent) : QSortFilterProxyModel(parent) { @@ -697,7 +707,8 @@ bool TreeProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_ } -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// ----------------------------------------------------------------------------------------------------- + HistoryDialog::HistoryDialog(QWidget *parent, HistoryManager *setHistory) : QDialog(parent) { @@ -766,7 +777,7 @@ void HistoryDialog::copy() } -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +// --------------------------------------------------------------------------------------------------------------- HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent) : QAbstractProxyModel(parent), @@ -954,8 +965,6 @@ void HistoryFilterModel::sourceRowsRemoved(const QModelIndex &, int start, int e } - -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ /* Removing a continuous block of rows will remove filtered rows too as this is the users intention. @@ -982,6 +991,9 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren } +// ------------------------------------------------------------------------------------------------------ + + HistoryCompletionModel::HistoryCompletionModel(QObject *parent) : QAbstractProxyModel(parent) { @@ -1082,8 +1094,8 @@ void HistoryCompletionModel::sourceReset() } +// ------------------------------------------------------------------------------------------------------ -// ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent) : QAbstractProxyModel(parent) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 54516e78..6f12220f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -236,6 +236,7 @@ void MainWindow::setupActions() m_historyBackMenu = new KMenu(this); historyBack->setMenu(m_historyBackMenu); connect(historyBack, SIGNAL( triggered(bool) ), this, SLOT( slotOpenPrevious() ) ); +// FIXME < --------------------------------------------------------------------------------------------------------------------------------------| connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); actionCollection()->addAction( QLatin1String("history back"), historyBack); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 882ae4e1..1c426c61 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -55,11 +55,23 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); + #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList&)), SLOT(sslErrors(QNetworkReply*, const QList&))); #endif + loadSettings(); + +#if QT_VERSION >= 0x040500 + + QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); + QString location = KStandardDirs::locateLocal("cache","",true); + diskCache->setCacheDirectory(location); + setCache(diskCache); + +#endif + } -- cgit v1.2.1 From 9e4dca9b627276d4558e9ec8a8475c136e7935f9 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 28 Mar 2009 15:48:24 +0100 Subject: scripts --- scripts/Messages.sh | 5 +++++ scripts/codingstyle.sh | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 scripts/Messages.sh create mode 100644 scripts/codingstyle.sh diff --git a/scripts/Messages.sh b/scripts/Messages.sh new file mode 100755 index 00000000..09ce1214 --- /dev/null +++ b/scripts/Messages.sh @@ -0,0 +1,5 @@ +# FIXME +#! /usr/bin/env bash +$EXTRACTRC `find . -name \*.ui -o -name \*.rc -o -name \*.kcfg` >> rc.cpp +$XGETTEXT `find . -name \*.cpp` -o $podir/rekonq.pot + diff --git a/scripts/codingstyle.sh b/scripts/codingstyle.sh new file mode 100644 index 00000000..ce24a5a1 --- /dev/null +++ b/scripts/codingstyle.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# apply kdelibs coding style to all c, cpp and header files in src directory +# requirements: installed astyle +# +# The coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style +# +# In rekonq we use some little different rules.. + +{ +cd .. +cd src + +astyle \ +--indent=spaces=4 \ +--brackets=break \ +--indent-labels \ +--pad=oper \ +--unpad=paren \ +--one-line=keep-statements \ +--convert-tabs \ +--indent-preprocessor \ +`find -type f -name '*.cpp'` `find -type f -name '*.h'` +} \ No newline at end of file -- cgit v1.2.1 From a934072cf9695e46e793898102590322f43c0733 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 28 Mar 2009 15:53:26 +0100 Subject: astyle. First round.. --- scripts/codingstyle.sh | 5 +- src/application.cpp | 30 ++-- src/application.h | 2 +- src/autosaver.cpp | 16 +- src/autosaver.h | 4 +- src/bookmarks.cpp | 68 ++++---- src/bookmarks.h | 38 ++--- src/cookiejar.cpp | 284 ++++++++++++++++++---------------- src/download.cpp | 56 +++---- src/download.h | 54 +++---- src/edittableview.cpp | 11 +- src/edittreeview.cpp | 11 +- src/findbar.cpp | 32 ++-- src/findbar.h | 2 +- src/history.cpp | 310 +++++++++++++++++++++---------------- src/history.h | 33 ++-- src/main.cpp | 36 ++--- src/mainview.cpp | 107 ++++++------- src/mainview.h | 4 +- src/mainwindow.cpp | 358 +++++++++++++++++++++---------------------- src/mainwindow.h | 4 +- src/modelmenu.cpp | 42 ++--- src/networkaccessmanager.cpp | 30 ++-- src/searchbar.cpp | 20 +-- src/searchbar.h | 6 +- src/settings.cpp | 48 +++--- src/settings.h | 2 +- src/tabbar.cpp | 26 ++-- src/tabbar.h | 4 +- src/urlbar.cpp | 26 ++-- src/urlbar.h | 2 +- src/webview.cpp | 94 ++++++------ src/webview.h | 18 ++- 33 files changed, 948 insertions(+), 835 deletions(-) mode change 100644 => 100755 scripts/codingstyle.sh diff --git a/scripts/codingstyle.sh b/scripts/codingstyle.sh old mode 100644 new mode 100755 index ce24a5a1..f0fb984f --- a/scripts/codingstyle.sh +++ b/scripts/codingstyle.sh @@ -8,6 +8,9 @@ # In rekonq we use some little different rules.. { +PWD=$(pwd) + +cd $PWD cd .. cd src @@ -21,4 +24,4 @@ astyle \ --convert-tabs \ --indent-preprocessor \ `find -type f -name '*.cpp'` `find -type f -name '*.h'` -} \ No newline at end of file +} diff --git a/src/application.cpp b/src/application.cpp index 6c621015..53b1cbce 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -59,17 +59,17 @@ NetworkAccessManager *Application::s_networkAccessManager = 0; Application::Application() - : KUniqueApplication() + : KUniqueApplication() { m_mainWindow = new MainWindow(); m_mainWindow->setObjectName("MainWindow"); - setWindowIcon( KIcon("rekonq") ); + setWindowIcon(KIcon("rekonq")); newTab(); mainWindow()->slotHome(); m_mainWindow->show(); - QTimer::singleShot(0, this, SLOT( postLaunch() ) ); + QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -85,16 +85,16 @@ int Application::newInstance() KCmdLineArgs::setCwd(QDir::currentPath().toUtf8()); KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); - if (args->count() > 0) + if (args->count() > 0) { - for (int i = 0; i < args->count(); ++i) + for (int i = 0; i < args->count(); ++i) { - KUrl url = MainWindow::guessUrlFromString( args->arg(i) ); + KUrl url = MainWindow::guessUrlFromString(args->arg(i)); newTab(); - mainWindow()->loadUrl( url ); + mainWindow()->loadUrl(url); } args->clear(); - } + } return 0; } @@ -108,9 +108,9 @@ Application *Application::instance() void Application::postLaunch() { - // set Icon Database Path to store "favicons" associated with web sites - QString directory = KStandardDirs::locateLocal( "cache" , "" , true ); - if ( directory.isEmpty() ) + // set Icon Database Path to store "favicons" associated with web sites + QString directory = KStandardDirs::locateLocal("cache" , "" , true); + if (directory.isEmpty()) { directory = QDir::homePath() + QLatin1String("/.") + QCoreApplication::applicationName(); } @@ -122,7 +122,7 @@ void Application::postLaunch() void Application::downloadUrl(const KUrl &srcUrl, const KUrl &destUrl) { - new Download( srcUrl, destUrl ); + new Download(srcUrl, destUrl); } @@ -152,7 +152,7 @@ CookieJar *Application::cookieJar() NetworkAccessManager *Application::networkAccessManager() { - if (!s_networkAccessManager) + if (!s_networkAccessManager) { s_networkAccessManager = new NetworkAccessManager(); s_networkAccessManager->setCookieJar(new CookieJar); @@ -164,7 +164,7 @@ NetworkAccessManager *Application::networkAccessManager() HistoryManager *Application::historyManager() { - if (!s_historyManager) + if (!s_historyManager) { s_historyManager = new HistoryManager(); QWebHistoryInterface::setDefaultInterface(s_historyManager); @@ -175,7 +175,7 @@ HistoryManager *Application::historyManager() KIcon Application::icon(const KUrl &url) const { - KIcon icon = KIcon( QWebSettings::iconForUrl(url) ); + KIcon icon = KIcon(QWebSettings::iconForUrl(url)); if (icon.isNull()) { icon = KIcon("kde"); diff --git a/src/application.h b/src/application.h index 438638c9..fa731c4e 100644 --- a/src/application.h +++ b/src/application.h @@ -39,7 +39,7 @@ class HistoryManager; class NetworkAccessManager; /** - * + * */ class Application : public KUniqueApplication { diff --git a/src/autosaver.cpp b/src/autosaver.cpp index a2ec7be5..b09f35e9 100644 --- a/src/autosaver.cpp +++ b/src/autosaver.cpp @@ -52,9 +52,12 @@ void AutoSaver::changeOccurred() if (m_firstChange.isNull()) m_firstChange.start(); - if (m_firstChange.elapsed() > MAXWAIT) { + if (m_firstChange.elapsed() > MAXWAIT) + { saveIfNeccessary(); - } else { + } + else + { m_timer.start(AUTOSAVE_IN, this); } } @@ -62,9 +65,12 @@ void AutoSaver::changeOccurred() void AutoSaver::timerEvent(QTimerEvent *event) { - if (event->timerId() == m_timer.timerId()) { + if (event->timerId() == m_timer.timerId()) + { saveIfNeccessary(); - } else { + } + else + { QObject::timerEvent(event); } } @@ -76,7 +82,7 @@ void AutoSaver::saveIfNeccessary() return; m_timer.stop(); m_firstChange = QTime(); - if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) + if (!QMetaObject::invokeMethod(parent(), "save", Qt::DirectConnection)) { kWarning() << "AutoSaver: error invoking slot save() on parent"; } diff --git a/src/autosaver.h b/src/autosaver.h index a686e11e..8d85a78d 100644 --- a/src/autosaver.h +++ b/src/autosaver.h @@ -30,9 +30,9 @@ It will wait several seconds after changed() to combining multiple changes and prevent continuous writing to disk. */ -class AutoSaver : public QObject +class AutoSaver : public QObject { -Q_OBJECT + Q_OBJECT public: AutoSaver(QObject *parent); diff --git a/src/bookmarks.cpp b/src/bookmarks.cpp index ab207736..da8b3908 100644 --- a/src/bookmarks.cpp +++ b/src/bookmarks.cpp @@ -39,19 +39,19 @@ OwnBookMarks::OwnBookMarks(KMainWindow *parent) - : QObject(parent) - , KBookmarkOwner() + : QObject(parent) + , KBookmarkOwner() { - m_parent = qobject_cast( parent ); - connect( this, SIGNAL( openUrl( const KUrl &) ) , parent , SLOT( loadUrl( const KUrl & ) ) ); + m_parent = qobject_cast(parent); + connect(this, SIGNAL(openUrl(const KUrl &)) , parent , SLOT(loadUrl(const KUrl &))); } -void OwnBookMarks::openBookmark (const KBookmark & b, Qt::MouseButtons mb, Qt::KeyboardModifiers km) +void OwnBookMarks::openBookmark(const KBookmark & b, Qt::MouseButtons mb, Qt::KeyboardModifiers km) { Q_UNUSED(mb); Q_UNUSED(km); - emit openUrl( b.url() ); + emit openUrl(b.url()); } @@ -65,22 +65,22 @@ QString OwnBookMarks::currentUrl() const QString OwnBookMarks::currentTitle() const { QString title = m_parent->windowTitle(); - return title.remove( " - rekonq" ); + return title.remove(" - rekonq"); } // ------------------------------------------------------------------------------------------------------ -BookmarksMenu::BookmarksMenu( KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac ) - : KBookmarkMenu(manager, owner, menu, ac) -{ +BookmarksMenu::BookmarksMenu(KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac) + : KBookmarkMenu(manager, owner, menu, ac) +{ } KMenu* BookmarksMenu::viewContextMenu(QAction* action) { - return contextMenu( action ); + return contextMenu(action); } @@ -88,17 +88,17 @@ KMenu* BookmarksMenu::viewContextMenu(QAction* action) BookmarksProvider::BookmarksProvider(KMainWindow* parent) - : m_parent(parent) - , m_owner(new OwnBookMarks(parent)) - , m_bmMenu(0) - , m_bmToolbar(0) + : m_parent(parent) + , m_owner(new OwnBookMarks(parent)) + , m_bmMenu(0) + , m_bmToolbar(0) { - KUrl bookfile = KUrl( "~/.kde/share/apps/konqueror/bookmarks.xml" ); // share konqueror bookmarks + KUrl bookfile = KUrl("~/.kde/share/apps/konqueror/bookmarks.xml"); // share konqueror bookmarks - if (!QFile::exists( bookfile.path() ) ) + if (!QFile::exists(bookfile.path())) { - bookfile = KUrl( "~/.kde4/share/apps/konqueror/bookmarks.xml" ); - if (!QFile::exists( bookfile.path() ) ) + bookfile = KUrl("~/.kde4/share/apps/konqueror/bookmarks.xml"); + if (!QFile::exists(bookfile.path())) { QString bookmarksDefaultPath = KStandardDirs::locate("appdata" , "defaultbookmarks.xbel"); kWarning() << bookmarksDefaultPath; @@ -107,13 +107,13 @@ BookmarksProvider::BookmarksProvider(KMainWindow* parent) bookmarksPath.replace("rekonq", "konqueror"); bkms.copy(bookmarksPath); - bookfile = KUrl( bookmarksPath ); + bookfile = KUrl(bookmarksPath); } } - m_manager = KBookmarkManager::managerForExternalFile( bookfile.path() ); - m_ac = new KActionCollection( this ); + m_manager = KBookmarkManager::managerForExternalFile(bookfile.path()); + m_ac = new KActionCollection(this); - connect( m_manager, SIGNAL( changed(const QString &, const QString &) ), this, SLOT( slotBookmarksChanged(const QString &) ) ); + connect(m_manager, SIGNAL(changed(const QString &, const QString &)), this, SLOT(slotBookmarksChanged(const QString &))); } @@ -122,7 +122,7 @@ void BookmarksProvider::slotBookmarksChanged(const QString & group) KBookmarkGroup toolbarGroup = m_manager->toolbar(); kWarning() << "KBookmarkBar::slotBookmarksChanged( " << group << " )"; - if ( toolbarGroup.isNull() ) + if (toolbarGroup.isNull()) return; m_bmToolbar->clear(); @@ -133,22 +133,22 @@ void BookmarksProvider::slotBookmarksChanged(const QString & group) void BookmarksProvider::provideBmToolbar(KToolBar* toolbar) { m_bmToolbar = toolbar; - toolbar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon ); + toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - toolbar->setContextMenuPolicy( Qt::CustomContextMenu ); - connect( toolbar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &)) ); + toolbar->setContextMenuPolicy(Qt::CustomContextMenu); + connect(toolbar, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenu(const QPoint &))); KBookmarkGroup toolbarGroup = m_manager->toolbar(); KBookmark bm = toolbarGroup.first(); - while(!bm.isNull()) + while (!bm.isNull()) { - if(bm.isGroup()) + if (bm.isGroup()) { // do nothing! } else { - if(bm.isSeparator()) + if (bm.isSeparator()) { toolbar->addSeparator(); } @@ -167,18 +167,18 @@ void BookmarksProvider::provideBmToolbar(KToolBar* toolbar) KMenu *BookmarksProvider::bookmarksMenu() { KMenu *menu = new KMenu(m_parent); - m_bmMenu = new BookmarksMenu( m_manager, m_owner, menu, m_ac ); + m_bmMenu = new BookmarksMenu(m_manager, m_owner, menu, m_ac); return menu; } void BookmarksProvider::contextMenu(const QPoint & point) { - KAction* action = dynamic_cast( m_bmToolbar->actionAt( point ) ); - if(!action) + KAction* action = dynamic_cast(m_bmToolbar->actionAt(point)); + if (!action) return; KMenu *menu = m_bmMenu->viewContextMenu(action); menu->setAttribute(Qt::WA_DeleteOnClose); - menu->popup( m_bmToolbar->mapToGlobal( point )); + menu->popup(m_bmToolbar->mapToGlobal(point)); } diff --git a/src/bookmarks.h b/src/bookmarks.h index 9ef82624..f31cea62 100644 --- a/src/bookmarks.h +++ b/src/bookmarks.h @@ -37,8 +37,8 @@ class MainWindow; -/** - * Inherited from KBookmarkOwner, this class allows to manage +/** + * Inherited from KBookmarkOwner, this class allows to manage * bookmarks as actions * * @author Andrea Diamantini @@ -46,21 +46,21 @@ class MainWindow; */ class OwnBookMarks : public QObject , public KBookmarkOwner { -Q_OBJECT + Q_OBJECT public: - /** + /** * The class ctor. * * @param parent the pointer to the browser mainwindow. We need it - * to link bookmarks actions with the right window + * to link bookmarks actions with the right window * where load url in */ OwnBookMarks(KMainWindow *parent); /** - * This function is called when a bookmark is selected and belongs to + * This function is called when a bookmark is selected and belongs to * the ancestor class. * This method actually emits signal to load bookmark's url without * considering mousebuttons or keyboard modifiers. @@ -69,10 +69,10 @@ public: * @param mb the mouse buttons clicked to select the bookmark * @param km the keyboard modifiers pushed when the bookmark was selected */ - virtual void openBookmark (const KBookmark &b , Qt::MouseButtons mb, Qt::KeyboardModifiers km); + virtual void openBookmark(const KBookmark &b , Qt::MouseButtons mb, Qt::KeyboardModifiers km); + - - /** + /** * this method, from KBookmarkOwner interface, allows to add the current page * to the bookmark list, returning the URL page as QString. * @@ -80,7 +80,7 @@ public: */ virtual QString currentUrl() const; - /** + /** * this method, from KBookmarkOwner interface, allows to add the current page * to the bookmark list, returning the title's page as QString. * @@ -90,7 +90,7 @@ public: signals: /** - * This signal is emitted when an url has to be loaded + * This signal is emitted when an url has to be loaded * * @param url the URL to load * @@ -106,7 +106,7 @@ private: // ------------------------------------------------------------------------------ -/** +/** * This class represent the rekonq bookmarks menu. * It's just a simple class inherited from KBookmarkMenu * @@ -116,10 +116,10 @@ private: */ class BookmarksMenu : public KBookmarkMenu { -Q_OBJECT + Q_OBJECT public: - BookmarksMenu( KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac); + BookmarksMenu(KBookmarkManager* manager, KBookmarkOwner* owner, KMenu* menu, KActionCollection* ac); KMenu *viewContextMenu(QAction* action); }; @@ -128,7 +128,7 @@ public: // ------------------------------------------------------------------------------ -/** +/** * This class represent the interface to rekonq bookmarks system. * All rekonq needs (Bookmarks Menu, Bookmarks Toolbar) is provided * from this class. @@ -140,10 +140,10 @@ public: */ class BookmarksProvider : public QObject { -Q_OBJECT + Q_OBJECT public: - /** + /** * Class constructor. Connect BookmarksProvider with bookmarks source * (actually konqueror's bookmarks) * @@ -152,14 +152,14 @@ public: */ BookmarksProvider(KMainWindow* parent); - /** + /** * Customize bookmarks toolbar * * @param toolbar the toolbar to customize */ void provideBmToolbar(KToolBar* toolbar); - /** + /** * Generate the Bookmarks Menu * * @return the Bookmarks Menu diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index d4ecb3f2..e74dd8e4 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -66,12 +66,12 @@ QDataStream &operator>>(QDataStream &stream, QList &list) quint32 count; stream >> count; - for(quint32 i = 0; i < count; ++i) + for (quint32 i = 0; i < count; ++i) { QByteArray value; stream >> value; QList newCookies = QNetworkCookie::parseCookies(value); - if (newCookies.count() == 0 && value.length() != 0) + if (newCookies.count() == 0 && value.length() != 0) { kWarning() << "CookieJar: Unable to parse saved cookie:" << value; } @@ -85,10 +85,10 @@ QDataStream &operator>>(QDataStream &stream, QList &list) CookieJar::CookieJar(QObject *parent) - : QNetworkCookieJar(parent) - , m_loaded(false) - , m_saveTimer(new AutoSaver(this)) - , m_acceptCookies(AcceptOnlyFromSitesNavigatedTo) + : QNetworkCookieJar(parent) + , m_loaded(false) + , m_saveTimer(new AutoSaver(this)) + , m_acceptCookies(AcceptOnlyFromSitesNavigatedTo) { } @@ -117,26 +117,26 @@ void CookieJar::load() qRegisterMetaTypeStreamOperators >("QList"); QString filepath = KStandardDirs::locateLocal("appdata", "cookies.ini"); - KConfig iniconfig( filepath ); + KConfig iniconfig(filepath); KConfigGroup inigroup1 = iniconfig.group("general"); - QStringList cookieStringList = inigroup1.readEntry( QString("cookies"), QStringList() ); + QStringList cookieStringList = inigroup1.readEntry(QString("cookies"), QStringList()); QList cookieNetworkList; - foreach( QString str, cookieStringList ) + foreach(QString str, cookieStringList) { - cookieNetworkList << QNetworkCookie( str.toLocal8Bit() ); + cookieNetworkList << QNetworkCookie(str.toLocal8Bit()); } - setAllCookies( cookieNetworkList ); + setAllCookies(cookieNetworkList); KConfigGroup inigroup2 = iniconfig.group("exceptions"); - m_exceptions_block = inigroup2.readEntry( QString("block") , QStringList() ); - m_exceptions_allow = inigroup2.readEntry( QString("allow"), QStringList() ); - m_exceptions_allowForSession = inigroup2.readEntry( QString("allowForSession"), QStringList() ); + m_exceptions_block = inigroup2.readEntry(QString("block") , QStringList()); + m_exceptions_allow = inigroup2.readEntry(QString("allow"), QStringList()); + m_exceptions_allowForSession = inigroup2.readEntry(QString("allowForSession"), QStringList()); - qSort( m_exceptions_block.begin(), m_exceptions_block.end() ); - qSort( m_exceptions_allow.begin(), m_exceptions_allow.end() ); - qSort( m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end() ); + qSort(m_exceptions_block.begin(), m_exceptions_block.end()); + qSort(m_exceptions_allow.begin(), m_exceptions_allow.end()); + qSort(m_exceptions_allowForSession.begin(), m_exceptions_allowForSession.end()); loadSettings(); } @@ -146,7 +146,7 @@ void CookieJar::loadSettings() { int canAcceptCookies = ReKonfig::acceptCookies(); - switch(canAcceptCookies) + switch (canAcceptCookies) { case 0: m_acceptCookies = AcceptAlways; @@ -162,7 +162,7 @@ void CookieJar::loadSettings() int canKeepCookiesUntil = ReKonfig::keepCookiesUntil(); - switch(canKeepCookiesUntil) + switch (canKeepCookiesUntil) { default: case 0: @@ -176,7 +176,7 @@ void CookieJar::loadSettings() m_keepCookies = KeepUntilTimeLimit; break; } - + m_loaded = true; emit cookiesChanged(); } @@ -187,33 +187,33 @@ void CookieJar::save() if (!m_loaded) return; purgeOldCookies(); - + QString filepath = KStandardDirs::locateLocal("appdata", "cookies.ini"); - KConfig iniconfig( filepath ); + KConfig iniconfig(filepath); KConfigGroup inigroup1 = iniconfig.group("general"); QList cookies = allCookies(); - for (int i = cookies.count() - 1; i >= 0; --i) + for (int i = cookies.count() - 1; i >= 0; --i) { if (cookies.at(i).isSessionCookie()) cookies.removeAt(i); } QStringList cookieStringList; - foreach( QNetworkCookie cook, cookies ) + foreach(QNetworkCookie cook, cookies) { - cookieStringList << QString( cook.toRawForm() ); + cookieStringList << QString(cook.toRawForm()); } - inigroup1.writeEntry( QString("cookies"), cookieStringList ); - + inigroup1.writeEntry(QString("cookies"), cookieStringList); + KConfigGroup inigroup2 = iniconfig.group("exceptions"); - inigroup2.writeEntry( QString("block"), m_exceptions_block ); - inigroup2.writeEntry( QString("allow"), m_exceptions_allow ); - inigroup2.writeEntry( QString("allowForSession"), m_exceptions_allowForSession ); + inigroup2.writeEntry(QString("block"), m_exceptions_block); + inigroup2.writeEntry(QString("allow"), m_exceptions_allow); + inigroup2.writeEntry(QString("allowForSession"), m_exceptions_allowForSession); // save cookie settings int n; - switch(m_acceptCookies) + switch (m_acceptCookies) { case AcceptAlways: n = 0; @@ -229,7 +229,7 @@ void CookieJar::save() ReKonfig::setAcceptCookies(n); - switch(m_keepCookies) + switch (m_keepCookies) { default: case KeepUntilExpire: @@ -253,7 +253,7 @@ void CookieJar::purgeOldCookies() return; int oldCount = cookies.count(); QDateTime now = QDateTime::currentDateTime(); - for (int i = cookies.count() - 1; i >= 0; --i) + for (int i = cookies.count() - 1; i >= 0; --i) { if (!cookies.at(i).isSessionCookie() && cookies.at(i).expirationDate() < now) cookies.removeAt(i); @@ -299,29 +299,29 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const bool addedCookies = false; // pass exceptions bool acceptInitially = (m_acceptCookies != AcceptNever); - if ( (acceptInitially && !eBlock) || (!acceptInitially && (eAllow || eAllowSession) ) ) + if ((acceptInitially && !eBlock) || (!acceptInitially && (eAllow || eAllowSession))) { // pass url domain == cookie domain QDateTime soon = QDateTime::currentDateTime(); soon = soon.addDays(90); - foreach(QNetworkCookie cookie, cookieList) + foreach(QNetworkCookie cookie, cookieList) { QList lst; if (m_keepCookies == KeepUntilTimeLimit - && !cookie.isSessionCookie() - && cookie.expirationDate() > soon) + && !cookie.isSessionCookie() + && cookie.expirationDate() > soon) { - cookie.setExpirationDate(soon); + cookie.setExpirationDate(soon); } lst += cookie; if (QNetworkCookieJar::setCookiesFromUrl(lst, url)) { addedCookies = true; - } - else + } + else { // finally force it in if wanted - if (m_acceptCookies == AcceptAlways) + if (m_acceptCookies == AcceptAlways) { QList cookies = allCookies(); cookies += cookie; @@ -336,7 +336,7 @@ bool CookieJar::setCookiesFromUrl(const QList &cookieList, const } } - if (addedCookies) + if (addedCookies) { m_saveTimer->changeOccurred(); emit cookiesChanged(); @@ -441,8 +441,8 @@ void CookieJar::setAllowForSessionCookies(const QStringList &list) CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) - : QAbstractTableModel(parent) - , m_cookieJar(cookieJar) + : QAbstractTableModel(parent) + , m_cookieJar(cookieJar) { connect(m_cookieJar, SIGNAL(cookiesChanged()), this, SLOT(cookiesChanged())); m_cookieJar->load(); @@ -451,34 +451,37 @@ CookieModel::CookieModel(CookieJar *cookieJar, QObject *parent) QVariant CookieModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::SizeHintRole) { + if (role == Qt::SizeHintRole) + { QFont font; font.setPointSize(10); QFontMetrics fm(font); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; int width = fm.width(headerData(section, orientation, Qt::DisplayRole).toString()); return QSize(width, height); } - if (orientation == Qt::Horizontal) { + if (orientation == Qt::Horizontal) + { if (role != Qt::DisplayRole) return QVariant(); - switch (section) { - case 0: - return i18n("Website"); - case 1: - return i18n("Name"); - case 2: - return i18n("Path"); - case 3: - return i18n("Secure"); - case 4: - return i18n("Expires"); - case 5: - return i18n("Contents"); - default: - return QVariant(); + switch (section) + { + case 0: + return i18n("Website"); + case 1: + return i18n("Name"); + case 2: + return i18n("Path"); + case 3: + return i18n("Secure"); + case 4: + return i18n("Expires"); + case 5: + return i18n("Contents"); + default: + return QVariant(); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -493,30 +496,34 @@ QVariant CookieModel::data(const QModelIndex &index, int role) const if (index.row() < 0 || index.row() >= lst.size()) return QVariant(); - switch (role) { + switch (role) + { case Qt::DisplayRole: - case Qt::EditRole: { + case Qt::EditRole: + { QNetworkCookie cookie = lst.at(index.row()); - switch (index.column()) { - case 0: - return cookie.domain(); - case 1: - return cookie.name(); - case 2: - return cookie.path(); - case 3: - return cookie.isSecure(); - case 4: - return cookie.expirationDate(); - case 5: - return cookie.value(); - } + switch (index.column()) + { + case 0: + return cookie.domain(); + case 1: + return cookie.name(); + case 2: + return cookie.path(); + case 3: + return cookie.isSecure(); + case 4: + return cookie.expirationDate(); + case 5: + return cookie.value(); } - case Qt::FontRole:{ + } + case Qt::FontRole: + { QFont font; font.setPointSize(10); return font; - } + } } return QVariant(); @@ -542,7 +549,8 @@ bool CookieModel::removeRows(int row, int count, const QModelIndex &parent) int lastRow = row + count - 1; beginRemoveRows(parent, row, lastRow); QList lst = m_cookieJar->allCookies(); - for (int i = lastRow; i >= row; --i) { + for (int i = lastRow; i >= row; --i) + { lst.removeAt(i); } m_cookieJar->setAllCookies(lst); @@ -561,8 +569,8 @@ void CookieModel::cookiesChanged() // ------------------------------------------------------------------------------------------------ -CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) - : QDialog(parent) +CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) + : QDialog(parent) { setupUi(this); setWindowFlags(Qt::Sheet); @@ -583,12 +591,14 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) QFont f = font(); f.setPointSize(10); QFontMetrics fm(f); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; cookiesTable->verticalHeader()->setDefaultSectionSize(height); cookiesTable->verticalHeader()->setMinimumSectionSize(-1); - for (int i = 0; i < model->columnCount(); ++i){ + for (int i = 0; i < model->columnCount(); ++i) + { int header = cookiesTable->horizontalHeader()->sectionSizeHint(i); - switch (i) { + switch (i) + { case 0: header = fm.width(QLatin1String("averagehost.domain.com")); break; @@ -611,8 +621,8 @@ CookiesDialog::CookiesDialog(CookieJar *cookieJar, QWidget *parent) CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *parent) - : QAbstractTableModel(parent) - , m_cookieJar(cookiejar) + : QAbstractTableModel(parent) + , m_cookieJar(cookiejar) { m_allowedCookies = m_cookieJar->allowedCookies(); m_blockedCookies = m_cookieJar->blockedCookies(); @@ -622,22 +632,25 @@ CookieExceptionsModel::CookieExceptionsModel(CookieJar *cookiejar, QObject *pare QVariant CookieExceptionsModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (role == Qt::SizeHintRole) { + if (role == Qt::SizeHintRole) + { QFont font; font.setPointSize(10); QFontMetrics fm(font); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; int width = fm.width(headerData(section, orientation, Qt::DisplayRole).toString()); return QSize(width, height); } if (orientation == Qt::Horizontal - && role == Qt::DisplayRole) { - switch (section) { - case 0: - return i18n("Website"); - case 1: - return i18n("Status"); + && role == Qt::DisplayRole) + { + switch (section) + { + case 0: + return i18n("Website"); + case 1: + return i18n("Status"); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -649,42 +662,51 @@ QVariant CookieExceptionsModel::data(const QModelIndex &index, int role) const if (index.row() < 0 || index.row() >= rowCount()) return QVariant(); - switch (role) { + switch (role) + { case Qt::DisplayRole: - case Qt::EditRole: { + case Qt::EditRole: + { int row = index.row(); - if (row < m_allowedCookies.count()) { - switch (index.column()) { - case 0: - return m_allowedCookies.at(row); - case 1: - return i18n("Allow"); + if (row < m_allowedCookies.count()) + { + switch (index.column()) + { + case 0: + return m_allowedCookies.at(row); + case 1: + return i18n("Allow"); } } row = row - m_allowedCookies.count(); - if (row < m_blockedCookies.count()) { - switch (index.column()) { - case 0: - return m_blockedCookies.at(row); - case 1: - return i18n("Block"); + if (row < m_blockedCookies.count()) + { + switch (index.column()) + { + case 0: + return m_blockedCookies.at(row); + case 1: + return i18n("Block"); } } row = row - m_blockedCookies.count(); - if (row < m_sessionCookies.count()) { - switch (index.column()) { - case 0: - return m_sessionCookies.at(row); - case 1: - return i18n("Allow For Session"); + if (row < m_sessionCookies.count()) + { + switch (index.column()) + { + case 0: + return m_sessionCookies.at(row); + case 1: + return i18n("Allow For Session"); } } - } - case Qt::FontRole:{ + } + case Qt::FontRole: + { QFont font; font.setPointSize(10); return font; - } + } } return QVariant(); } @@ -709,18 +731,22 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa int lastRow = row + count - 1; beginRemoveRows(parent, row, lastRow); - for (int i = lastRow; i >= row; --i) { - if (i < m_allowedCookies.count()) { + for (int i = lastRow; i >= row; --i) + { + if (i < m_allowedCookies.count()) + { m_allowedCookies.removeAt(row); continue; } i = i - m_allowedCookies.count(); - if (i < m_blockedCookies.count()) { + if (i < m_blockedCookies.count()) + { m_blockedCookies.removeAt(row); continue; } i = i - m_blockedCookies.count(); - if (i < m_sessionCookies.count()) { + if (i < m_sessionCookies.count()) + { m_sessionCookies.removeAt(row); continue; } @@ -737,8 +763,8 @@ bool CookieExceptionsModel::removeRows(int row, int count, const QModelIndex &pa CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget *parent) - : QDialog(parent) - , m_cookieJar(cookieJar) + : QDialog(parent) + , m_cookieJar(cookieJar) { setupUi(this); setWindowFlags(Qt::Sheet); @@ -769,12 +795,14 @@ CookiesExceptionsDialog::CookiesExceptionsDialog(CookieJar *cookieJar, QWidget * QFont f = font(); f.setPointSize(10); QFontMetrics fm(f); - int height = fm.height() + fm.height()/3; + int height = fm.height() + fm.height() / 3; exceptionTable->verticalHeader()->setDefaultSectionSize(height); exceptionTable->verticalHeader()->setMinimumSectionSize(-1); - for (int i = 0; i < m_exceptionsModel->columnCount(); ++i){ + for (int i = 0; i < m_exceptionsModel->columnCount(); ++i) + { int header = exceptionTable->horizontalHeader()->sectionSizeHint(i); - switch (i) { + switch (i) + { case 0: header = fm.width(QLatin1String("averagebiglonghost.domain.com")); break; diff --git a/src/download.cpp b/src/download.cpp index deba9a53..7edc8dc6 100644 --- a/src/download.cpp +++ b/src/download.cpp @@ -30,12 +30,12 @@ #include Download::Download(const KUrl &srcUrl, const KUrl &destUrl) - : m_srcUrl(srcUrl), - m_destUrl(destUrl) + : m_srcUrl(srcUrl), + m_destUrl(destUrl) { kWarning() << "DownloadFile: " << m_srcUrl.url() << " to dest: " << m_destUrl.url(); m_copyJob = KIO::get(m_srcUrl); - connect(m_copyJob, SIGNAL(data(KIO::Job*,const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); + connect(m_copyJob, SIGNAL(data(KIO::Job*, const QByteArray &)), SLOT(slotData(KIO::Job*, const QByteArray&))); connect(m_copyJob, SIGNAL(result(KJob *)), SLOT(slotResult(KJob *))); } @@ -53,34 +53,34 @@ void Download::slotResult(KJob * job) { switch (job->error()) { - case 0://The download has finished + case 0://The download has finished + { + kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); + QFile destFile(m_destUrl.path()); + int n = 1; + QString fn = destFile.fileName(); + while (destFile.exists()) { - kDebug(5001) << "Downloading successfully finished: " << m_destUrl.url(); - QFile destFile(m_destUrl.path()); - int n = 1; - QString fn = destFile.fileName(); - while( destFile.exists() ) - { - destFile.setFileName( fn + "." + QString::number(n) ); - n++; - } - if ( destFile.open(QIODevice::WriteOnly | QIODevice::Text) ) - { - destFile.write(m_data); - destFile.close(); - } - m_data = 0; - break; + destFile.setFileName(fn + "." + QString::number(n)); + n++; } - case KIO::ERR_FILE_ALREADY_EXIST: + if (destFile.open(QIODevice::WriteOnly | QIODevice::Text)) { - kWarning() << "ERROR - File already exists"; - m_data = 0; - break; + destFile.write(m_data); + destFile.close(); } - default: - kWarning() << "We are sorry to say you, that there were errors while downloading :("; - m_data = 0; - break; + m_data = 0; + break; + } + case KIO::ERR_FILE_ALREADY_EXIST: + { + kWarning() << "ERROR - File already exists"; + m_data = 0; + break; + } + default: + kWarning() << "We are sorry to say you, that there were errors while downloading :("; + m_data = 0; + break; } } diff --git a/src/download.h b/src/download.h index a905e1ae..fe415c0b 100644 --- a/src/download.h +++ b/src/download.h @@ -31,41 +31,41 @@ /** * This class lets rekonq to download an object from the network. - * Creating a new object, you can continue downloading a file also + * Creating a new object, you can continue downloading a file also * when rekonq is closed. * - */ + */ class Download : public QObject { Q_OBJECT - public: - /** - * Class constructor. This is the unique method we need to - * use this class. In fact Download class needs to know just - * "where" catch the file to download and where it has to put it - * - * @param srcUrl the source url - * - * @param destUrl the destination url - * - */ - Download(const KUrl &srcUrl, const KUrl &destUrl); +public: + /** + * Class constructor. This is the unique method we need to + * use this class. In fact Download class needs to know just + * "where" catch the file to download and where it has to put it + * + * @param srcUrl the source url + * + * @param destUrl the destination url + * + */ + Download(const KUrl &srcUrl, const KUrl &destUrl); - /** - * class destructor - */ - ~Download(); + /** + * class destructor + */ + ~Download(); - private slots: - void slotResult(KJob * job); - void slotData(KIO::Job *job, const QByteArray& data); +private slots: + void slotResult(KJob * job); + void slotData(KIO::Job *job, const QByteArray& data); - private: - KIO::TransferJob *m_copyJob; - KUrl m_srcUrl; - KUrl m_destUrl; - KUrl m_destFile; - QByteArray m_data; +private: + KIO::TransferJob *m_copyJob; + KUrl m_srcUrl; + KUrl m_destUrl; + KUrl m_destFile; + QByteArray m_data; }; #endif diff --git a/src/edittableview.cpp b/src/edittableview.cpp index ea916c8d..2f35e9f3 100644 --- a/src/edittableview.cpp +++ b/src/edittableview.cpp @@ -24,17 +24,20 @@ #include EditTableView::EditTableView(QWidget *parent) - : QTableView(parent) + : QTableView(parent) { } void EditTableView::keyPressEvent(QKeyEvent *event) { if ((event->key() == Qt::Key_Delete - || event->key() == Qt::Key_Backspace) - && model()) { + || event->key() == Qt::Key_Backspace) + && model()) + { removeOne(); - } else { + } + else + { QAbstractItemView::keyPressEvent(event); } } diff --git a/src/edittreeview.cpp b/src/edittreeview.cpp index 014e0415..747753de 100644 --- a/src/edittreeview.cpp +++ b/src/edittreeview.cpp @@ -25,17 +25,20 @@ #include EditTreeView::EditTreeView(QWidget *parent) - : QTreeView(parent) + : QTreeView(parent) { } void EditTreeView::keyPressEvent(QKeyEvent *event) { if ((event->key() == Qt::Key_Delete - || event->key() == Qt::Key_Backspace) - && model()) { + || event->key() == Qt::Key_Backspace) + && model()) + { removeOne(); - } else { + } + else + { QAbstractItemView::keyPressEvent(event); } } diff --git a/src/findbar.cpp b/src/findbar.cpp index 1c82aa4a..514ec56f 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -35,8 +35,8 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) - : QWidget() - , m_lineEdit(0) + : QWidget() + , m_lineEdit(0) { QHBoxLayout *layout = new QHBoxLayout; @@ -49,7 +49,7 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) hideButton->setIcon(KIcon("dialog-close")); connect(hideButton, SIGNAL(clicked()), this, SLOT(hide())); layout->addWidget(hideButton); - layout->setAlignment( hideButton, Qt::AlignLeft|Qt::AlignTop ); + layout->setAlignment(hideButton, Qt::AlignLeft | Qt::AlignTop); // label QLabel *label = new QLabel("Find: "); @@ -58,18 +58,18 @@ FindBar::FindBar(KXmlGuiWindow *mainwindow) // lineEdit, focusProxy m_lineEdit = new KLineEdit(this); setFocusProxy(m_lineEdit); - m_lineEdit->setMaximumWidth( 250 ); - connect( m_lineEdit, SIGNAL( textChanged(const QString &) ), mainwindow, SLOT( slotFind(const QString &) ) ); - layout->addWidget( m_lineEdit ); + m_lineEdit->setMaximumWidth(250); + connect(m_lineEdit, SIGNAL(textChanged(const QString &)), mainwindow, SLOT(slotFind(const QString &))); + layout->addWidget(m_lineEdit); // buttons - KPushButton *findNext = new KPushButton( KIcon("go-down"), "&Next", this ); - KPushButton *findPrev = new KPushButton( KIcon("go-up"), "&Previous", this ); - connect( findNext, SIGNAL( clicked() ), mainwindow, SLOT( slotFindNext() ) ); - connect( findPrev, SIGNAL( clicked() ), mainwindow, SLOT( slotFindPrevious() ) ); - layout->addWidget( findNext ); - layout->addWidget( findPrev ); - + KPushButton *findNext = new KPushButton(KIcon("go-down"), "&Next", this); + KPushButton *findPrev = new KPushButton(KIcon("go-up"), "&Previous", this); + connect(findNext, SIGNAL(clicked()), mainwindow, SLOT(slotFindNext())); + connect(findPrev, SIGNAL(clicked()), mainwindow, SLOT(slotFindPrevious())); + layout->addWidget(findNext); + layout->addWidget(findPrev); + // stretching widget on the left layout->addStretch(); @@ -100,7 +100,7 @@ void FindBar::clear() void FindBar::showFindBar() { - if (!isVisible()) + if (!isVisible()) { show(); } @@ -116,9 +116,9 @@ void FindBar::keyPressEvent(QKeyEvent* event) hide(); return; } - if(event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty() ) + if (event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty()) { - emit searchString( m_lineEdit->text() ); + emit searchString(m_lineEdit->text()); return; } QWidget::keyPressEvent(event); diff --git a/src/findbar.h b/src/findbar.h index 4763944b..66286cec 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -39,7 +39,7 @@ public: public slots: void clear(); void showFindBar(); - + protected Q_SLOTS: void keyPressEvent(QKeyEvent* event); diff --git a/src/history.cpp b/src/history.cpp index 5c545b10..96efd3e5 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -46,12 +46,12 @@ static const unsigned int HISTORY_VERSION = 23; HistoryManager::HistoryManager(QObject *parent) - : QWebHistoryInterface(parent) - , m_saveTimer(new AutoSaver(this)) - , m_historyLimit(30) - , m_historyModel(0) - , m_historyFilterModel(0) - , m_historyTreeModel(0) + : QWebHistoryInterface(parent) + , m_saveTimer(new AutoSaver(this)) + , m_historyLimit(30) + , m_historyModel(0) + , m_historyFilterModel(0) + , m_historyTreeModel(0) { m_expiredTimer.setSingleShot(true); connect(&m_expiredTimer, SIGNAL(timeout()), this, SLOT(checkForExpired())); @@ -106,9 +106,12 @@ void HistoryManager::setHistory(const QList &history, bool loadedAn checkForExpired(); - if (loadedAndSorted) { + if (loadedAndSorted) + { m_lastSavedUrl = m_history.value(0).url; - } else { + } + else + { m_lastSavedUrl = QString(); m_saveTimer->changeOccurred(); } @@ -142,13 +145,17 @@ void HistoryManager::checkForExpired() QDateTime now = QDateTime::currentDateTime(); int nextTimeout = 0; - while (!m_history.isEmpty()) { + while (!m_history.isEmpty()) + { QDateTime checkForExpired = m_history.last().dateTime; checkForExpired.setDate(checkForExpired.date().addDays(m_historyLimit)); - if (now.daysTo(checkForExpired) > 7) { + if (now.daysTo(checkForExpired) > 7) + { // check at most in a week to prevent int overflows on the timer nextTimeout = 7 * 86400; - } else { + } + else + { nextTimeout = now.secsTo(checkForExpired); } if (nextTimeout > 0) @@ -179,9 +186,9 @@ void HistoryManager::addHistoryItem(const HistoryItem &item) void HistoryManager::updateHistoryItem(const KUrl &url, const QString &title) { - for (int i = 0; i < m_history.count(); ++i) + for (int i = 0; i < m_history.count(); ++i) { - if (url == m_history.at(i).url) + if (url == m_history.at(i).url) { m_history[i].title = title; m_saveTimer->changeOccurred(); @@ -223,16 +230,16 @@ void HistoryManager::clear() void HistoryManager::loadSettings() { int historyExpire = ReKonfig::expireHistory(); - int days; - switch (historyExpire) + int days; + switch (historyExpire) { - case 0: days = 1; break; - case 1: days = 7; break; - case 2: days = 14; break; - case 3: days = 30; break; - case 4: days = 365; break; - case 5: days = -1; break; - default: days = -1; + case 0: days = 1; break; + case 1: days = 7; break; + case 2: days = 14; break; + case 3: days = 30; break; + case 4: days = 365; break; + case 5: days = -1; break; + default: days = -1; } m_historyLimit = days; } @@ -243,10 +250,10 @@ void HistoryManager::load() loadSettings(); QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history"); - QFile historyFile( historyFilePath ); + QFile historyFile(historyFilePath); if (!historyFile.exists()) return; - if (!historyFile.open(QFile::ReadOnly)) + if (!historyFile.open(QFile::ReadOnly)) { kWarning() << "Unable to open history file" << historyFile.fileName(); return; @@ -261,7 +268,7 @@ void HistoryManager::load() QDataStream stream; QBuffer buffer; stream.setDevice(&buffer); - while ( !historyFile.atEnd() ) + while (!historyFile.atEnd()) { in >> data; buffer.close(); @@ -279,26 +286,26 @@ void HistoryManager::load() if (!item.dateTime.isValid()) continue; - if ( item == lastInsertedItem ) + if (item == lastInsertedItem) { if (lastInsertedItem.title.isEmpty() && !list.isEmpty()) list[0].title = item.title; continue; } - if ( !needToSort && !list.isEmpty() && lastInsertedItem < item ) + if (!needToSort && !list.isEmpty() && lastInsertedItem < item) needToSort = true; list.prepend(item); lastInsertedItem = item; } if (needToSort) - qSort( list.begin(), list.end() ); + qSort(list.begin(), list.end()); setHistory(list, true); // If we had to sort re-write the whole history sorted - if (needToSort) + if (needToSort) { m_lastSavedUrl = QString(); m_saveTimer->changeOccurred(); @@ -310,12 +317,12 @@ void HistoryManager::save() { bool saveAll = m_lastSavedUrl.isEmpty(); int first = m_history.count() - 1; - if (!saveAll) + if (!saveAll) { // find the first one to save - for (int i = 0; i < m_history.count(); ++i) + for (int i = 0; i < m_history.count(); ++i) { - if (m_history.at(i).url == m_lastSavedUrl) + if (m_history.at(i).url == m_lastSavedUrl) { first = i - 1; break; @@ -326,30 +333,30 @@ void HistoryManager::save() saveAll = true; QString historyFilePath = KStandardDirs::locateLocal("appdata" , "history"); - QFile historyFile( historyFilePath ); + QFile historyFile(historyFilePath); // When saving everything use a temporary file to prevent possible data loss. QTemporaryFile tempFile; tempFile.setAutoRemove(false); bool open = false; - if (saveAll) + if (saveAll) { open = tempFile.open(); } - else + else { open = historyFile.open(QFile::Append); } - if (!open) + if (!open) { kWarning() << "Unable to open history file for saving" - << (saveAll ? tempFile.fileName() : historyFile.fileName()); + << (saveAll ? tempFile.fileName() : historyFile.fileName()); return; } QDataStream out(saveAll ? &tempFile : &historyFile); - for (int i = first; i >= 0; --i) + for (int i = first; i >= 0; --i) { QByteArray data; QDataStream stream(&data, QIODevice::WriteOnly); @@ -359,7 +366,7 @@ void HistoryManager::save() } tempFile.close(); - if (saveAll) + if (saveAll) { if (historyFile.exists() && !historyFile.remove()) kWarning() << "History: error removing old history." << historyFile.errorString(); @@ -374,8 +381,8 @@ void HistoryManager::save() HistoryModel::HistoryModel(HistoryManager *history, QObject *parent) - : QAbstractTableModel(parent) - , m_history(history) + : QAbstractTableModel(parent) + , m_history(history) { Q_ASSERT(m_history); connect(m_history, SIGNAL(historyReset()), this, SLOT(historyReset())); @@ -408,12 +415,12 @@ void HistoryModel::entryUpdated(int offset) QVariant HistoryModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal - && role == Qt::DisplayRole) + && role == Qt::DisplayRole) { - switch (section) + switch (section) { - case 0: return i18n("Title"); - case 1: return i18n("Address"); + case 0: return i18n("Title"); + case 1: return i18n("Address"); } } return QAbstractTableModel::headerData(section, orientation, role); @@ -427,7 +434,7 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const return QVariant(); const HistoryItem &item = lst.at(index.row()); - switch (role) + switch (role) { case DateTimeRole: return item.dateTime; @@ -438,23 +445,27 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const case UrlStringRole: return item.url; case Qt::DisplayRole: - case Qt::EditRole: { - switch (index.column()) { - case 0: - // when there is no title try to generate one from the url - if (item.title.isEmpty()) { - QString page = QFileInfo(QUrl(item.url).path()).fileName(); - if (!page.isEmpty()) - return page; - return item.url; - } - return item.title; - case 1: + case Qt::EditRole: + { + switch (index.column()) + { + case 0: + // when there is no title try to generate one from the url + if (item.title.isEmpty()) + { + QString page = QFileInfo(QUrl(item.url).path()).fileName(); + if (!page.isEmpty()) + return page; return item.url; + } + return item.title; + case 1: + return item.url; } - } + } case Qt::DecorationRole: - if (index.column() == 0) { + if (index.column() == 0) + { return Application::instance()->icon(item.url); } } @@ -502,8 +513,8 @@ bool HistoryModel::removeRows(int row, int count, const QModelIndex &parent) Maps the first bunch of items of the source model to the root */ HistoryMenuModel::HistoryMenuModel(HistoryTreeModel *sourceModel, QObject *parent) - : QAbstractProxyModel(parent) - , m_treeModel(sourceModel) + : QAbstractProxyModel(parent) + , m_treeModel(sourceModel) { setSourceModel(sourceModel); } @@ -529,16 +540,18 @@ int HistoryMenuModel::rowCount(const QModelIndex &parent) const if (parent.column() > 0) return 0; - if (!parent.isValid()) { + if (!parent.isValid()) + { int folders = sourceModel()->rowCount(); int bumpedItems = bumpedRows(); if (bumpedItems <= MOVEDROWS - && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0))) + && bumpedItems == sourceModel()->rowCount(sourceModel()->index(0, 0))) --folders; return bumpedItems + folders; } - if (parent.internalId() == -1) { + if (parent.internalId() == -1) + { if (parent.row() < bumpedRows()) return 0; } @@ -565,7 +578,8 @@ QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const if (!proxyIndex.isValid()) return QModelIndex(); - if (proxyIndex.internalId() == -1) { + if (proxyIndex.internalId() == -1) + { int bumpedItems = bumpedRows(); if (proxyIndex.row() < bumpedItems) return m_treeModel->index(proxyIndex.row(), proxyIndex.column(), m_treeModel->index(0, 0)); @@ -583,8 +597,8 @@ QModelIndex HistoryMenuModel::mapToSource(const QModelIndex &proxyIndex) const QModelIndex HistoryMenuModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 - || column < 0 || column >= columnCount(parent) - || parent.column() > 0) + || column < 0 || column >= columnCount(parent) + || parent.column() > 0) return QModelIndex(); if (!parent.isValid()) return createIndex(row, column, -1); @@ -625,8 +639,8 @@ QModelIndex HistoryMenuModel::parent(const QModelIndex &index) const HistoryMenu::HistoryMenu(QWidget *parent) - : ModelMenu(parent) - , m_history(0) + : ModelMenu(parent) + , m_history(0) { connect(this, SIGNAL(activated(const QModelIndex &)), this, SLOT(activated(const QModelIndex &))); setHoverRole(HistoryModel::UrlStringRole); @@ -641,7 +655,7 @@ void HistoryMenu::activated(const QModelIndex &index) bool HistoryMenu::prePopulated() { - if (!m_history) + if (!m_history) { m_history = Application::historyManager(); m_historyMenuModel = new HistoryMenuModel(m_history->historyTreeModel(), this); @@ -663,11 +677,11 @@ void HistoryMenu::postPopulated() if (m_history->history().count() > 0) addSeparator(); - KAction *showAllAction = new KAction( i18n("Show All History"), this); + KAction *showAllAction = new KAction(i18n("Show All History"), this); connect(showAllAction, SIGNAL(triggered()), this, SLOT(showHistoryDialog())); addAction(showAllAction); - KAction *clearAction = new KAction( i18n("Clear History"), this); + KAction *clearAction = new KAction(i18n("Clear History"), this); connect(clearAction, SIGNAL(triggered()), m_history, SLOT(clear())); addAction(clearAction); } @@ -746,12 +760,13 @@ void HistoryDialog::customContextMenuRequested(const QPoint &pos) QMenu menu; QModelIndex index = tree->indexAt(pos); index = index.sibling(index.row(), 0); - if (index.isValid() && !tree->model()->hasChildren(index)) { - menu.addAction( i18n("Open"), this, SLOT(open())); + if (index.isValid() && !tree->model()->hasChildren(index)) + { + menu.addAction(i18n("Open"), this, SLOT(open())); menu.addSeparator(); - menu.addAction( i18n("Copy"), this, SLOT(copy())); + menu.addAction(i18n("Copy"), this, SLOT(copy())); } - menu.addAction( i18n("Delete"), tree, SLOT(removeOne())); + menu.addAction(i18n("Delete"), tree, SLOT(removeOne())); menu.exec(QCursor::pos()); } @@ -780,8 +795,8 @@ void HistoryDialog::copy() // --------------------------------------------------------------------------------------------------------------- HistoryFilterModel::HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent) - : QAbstractProxyModel(parent), - m_loaded(false) + : QAbstractProxyModel(parent), + m_loaded(false) { setSourceModel(sourceModel); } @@ -804,23 +819,25 @@ QVariant HistoryFilterModel::data(const QModelIndex &index, int role) const void HistoryFilterModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if (sourceModel()) { + if (sourceModel()) + { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(dataChanged(const QModelIndex &, const QModelIndex &))); disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); } QAbstractProxyModel::setSourceModel(newSourceModel); - if (sourceModel()) { + if (sourceModel()) + { m_loaded = false; connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &))); + this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &))); connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), @@ -885,8 +902,10 @@ QModelIndex HistoryFilterModel::mapFromSource(const QModelIndex &sourceIndex) co int realRow = -1; int sourceModelRow = sourceModel()->rowCount() - sourceIndex.row(); - for (int i = 0; i < m_sourceRow.count(); ++i) { - if (m_sourceRow.at(i) == sourceModelRow) { + for (int i = 0; i < m_sourceRow.count(); ++i) + { + if (m_sourceRow.at(i) == sourceModelRow) + { realRow = i; break; } @@ -902,7 +921,7 @@ QModelIndex HistoryFilterModel::index(int row, int column, const QModelIndex &pa { load(); if (row < 0 || row >= rowCount(parent) - || column < 0 || column >= columnCount(parent)) + || column < 0 || column >= columnCount(parent)) return QModelIndex(); return createIndex(row, column, m_sourceRow[row]); @@ -922,10 +941,12 @@ void HistoryFilterModel::load() const m_sourceRow.clear(); m_historyHash.clear(); m_historyHash.reserve(sourceModel()->rowCount()); - for (int i = 0; i < sourceModel()->rowCount(); ++i) { + for (int i = 0; i < sourceModel()->rowCount(); ++i) + { QModelIndex idx = sourceModel()->index(i, 0); QString url = idx.data(HistoryModel::UrlStringRole).toString(); - if (!m_historyHash.contains(url)) { + if (!m_historyHash.contains(url)) + { m_sourceRow.append(sourceModel()->rowCount() - i); m_historyHash[url] = sourceModel()->rowCount() - i; } @@ -942,7 +963,8 @@ void HistoryFilterModel::sourceRowsInserted(const QModelIndex &parent, int start return; QModelIndex idx = sourceModel()->index(start, 0, parent); QString url = idx.data(HistoryModel::UrlStringRole).toString(); - if (m_historyHash.contains(url)) { + if (m_historyHash.contains(url)) + { int sourceRow = sourceModel()->rowCount() - m_historyHash[url]; int realRow = mapFromSource(sourceModel()->index(sourceRow, 0)).row(); beginRemoveRows(QModelIndex(), realRow, realRow); @@ -975,7 +997,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren return false; int lastRow = row + count - 1; disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); beginRemoveRows(parent, row, lastRow); int oldCount = rowCount(); int start = sourceModel()->rowCount() - m_sourceRow.value(row); @@ -983,7 +1005,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren sourceModel()->removeRows(start, end - start + 1); endRemoveRows(); connect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); m_loaded = false; if (oldCount - count != rowCount()) reset(); @@ -995,7 +1017,7 @@ bool HistoryFilterModel::removeRows(int row, int count, const QModelIndex &paren HistoryCompletionModel::HistoryCompletionModel(QObject *parent) - : QAbstractProxyModel(parent) + : QAbstractProxyModel(parent) { } @@ -1003,12 +1025,14 @@ HistoryCompletionModel::HistoryCompletionModel(QObject *parent) QVariant HistoryCompletionModel::data(const QModelIndex &index, int role) const { if (sourceModel() - && (role == Qt::EditRole || role == Qt::DisplayRole) - && index.isValid()) { + && (role == Qt::EditRole || role == Qt::DisplayRole) + && index.isValid()) + { QModelIndex idx = mapToSource(index); idx = idx.sibling(idx.row(), 1); QString urlString = idx.data(HistoryModel::UrlStringRole).toString(); - if (index.row() % 2) { + if (index.row() % 2) + { QUrl url = urlString; QString s = url.toString(QUrl::RemoveScheme | QUrl::RemoveUserInfo @@ -1052,7 +1076,7 @@ QModelIndex HistoryCompletionModel::mapToSource(const QModelIndex &proxyIndex) c QModelIndex HistoryCompletionModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 || row >= rowCount(parent) - || column < 0 || column >= columnCount(parent)) + || column < 0 || column >= columnCount(parent)) return QModelIndex(); return createIndex(row, column, 0); } @@ -1066,17 +1090,19 @@ QModelIndex HistoryCompletionModel::parent(const QModelIndex &) const void HistoryCompletionModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if (sourceModel()) { + if (sourceModel()) + { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(sourceReset())); + this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceReset())); + this, SLOT(sourceReset())); } QAbstractProxyModel::setSourceModel(newSourceModel); - if (newSourceModel) { + if (newSourceModel) + { connect(newSourceModel, SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(sourceReset())); @@ -1098,7 +1124,7 @@ void HistoryCompletionModel::sourceReset() HistoryTreeModel::HistoryTreeModel(QAbstractItemModel *sourceModel, QObject *parent) - : QAbstractProxyModel(parent) + : QAbstractProxyModel(parent) { setSourceModel(sourceModel); } @@ -1112,25 +1138,30 @@ QVariant HistoryTreeModel::headerData(int section, Qt::Orientation orientation, QVariant HistoryTreeModel::data(const QModelIndex &index, int role) const { - if ((role == Qt::EditRole || role == Qt::DisplayRole)) { + if ((role == Qt::EditRole || role == Qt::DisplayRole)) + { int start = index.internalId(); - if (start == 0) { + if (start == 0) + { int offset = sourceDateRow(index.row()); - if (index.column() == 0) { + if (index.column() == 0) + { QModelIndex idx = sourceModel()->index(offset, 0); QDate date = idx.data(HistoryModel::DateRole).toDate(); if (date == QDate::currentDate()) return i18n("Earlier Today"); return date.toString(QLatin1String("dddd, MMMM d, yyyy")); } - if (index.column() == 1) { + if (index.column() == 1) + { return QString(rowCount(index.sibling(index.row(), 0))) + i18n(" items") ; } } } if (role == Qt::DecorationRole && index.column() == 0 && !index.parent().isValid()) return KIcon("view-history"); - if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) { + if (role == HistoryModel::DateRole && index.column() == 0 && index.internalId() == 0) + { int offset = sourceDateRow(index.row()); QModelIndex idx = sourceModel()->index(offset, 0); return idx.data(HistoryModel::DateRole); @@ -1148,22 +1179,25 @@ int HistoryTreeModel::columnCount(const QModelIndex &parent) const int HistoryTreeModel::rowCount(const QModelIndex &parent) const { - if ( parent.internalId() != 0 - || parent.column() > 0 - || !sourceModel()) + if (parent.internalId() != 0 + || parent.column() > 0 + || !sourceModel()) return 0; // row count OF dates - if (!parent.isValid()) { + if (!parent.isValid()) + { if (!m_sourceRowCache.isEmpty()) return m_sourceRowCache.count(); QDate currentDate; int rows = 0; int totalRows = sourceModel()->rowCount(); - for (int i = 0; i < totalRows; ++i) { + for (int i = 0; i < totalRows; ++i) + { QDate rowDate = sourceModel()->index(i, 0).data(HistoryModel::DateRole).toDate(); - if (rowDate != currentDate) { + if (rowDate != currentDate) + { m_sourceRowCache.append(i); currentDate = rowDate; ++rows; @@ -1189,7 +1223,8 @@ int HistoryTreeModel::sourceDateRow(int row) const if (m_sourceRowCache.isEmpty()) rowCount(QModelIndex()); - if (row >= m_sourceRowCache.count()) { + if (row >= m_sourceRowCache.count()) + { if (!sourceModel()) return 0; return sourceModel()->rowCount(); @@ -1211,8 +1246,8 @@ QModelIndex HistoryTreeModel::mapToSource(const QModelIndex &proxyIndex) const QModelIndex HistoryTreeModel::index(int row, int column, const QModelIndex &parent) const { if (row < 0 - || column < 0 || column >= columnCount(parent) - || parent.column() > 0) + || column < 0 || column >= columnCount(parent) + || parent.column() > 0) return QModelIndex(); if (!parent.isValid()) @@ -1252,13 +1287,17 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) if (row < 0 || count <= 0 || row + count > rowCount(parent)) return false; - if (parent.isValid()) { + if (parent.isValid()) + { // removing pages int offset = sourceDateRow(parent.row()); return sourceModel()->removeRows(offset + row, count); - } else { + } + else + { // removing whole dates - for (int i = row + count - 1; i >= row; --i) { + for (int i = row + count - 1; i >= row; --i) + { QModelIndex dateParent = index(i, 0); int offset = sourceDateRow(dateParent.row()); if (!sourceModel()->removeRows(offset, rowCount(dateParent))) @@ -1271,18 +1310,20 @@ bool HistoryTreeModel::removeRows(int row, int count, const QModelIndex &parent) void HistoryTreeModel::setSourceModel(QAbstractItemModel *newSourceModel) { - if (sourceModel()) { + if (sourceModel()) + { disconnect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); disconnect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), - this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); + this, SLOT(sourceRowsInserted(const QModelIndex &, int, int))); disconnect(sourceModel(), SIGNAL(rowsRemoved(const QModelIndex &, int, int)), - this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); + this, SLOT(sourceRowsRemoved(const QModelIndex &, int, int))); } QAbstractProxyModel::setSourceModel(newSourceModel); - if (newSourceModel) { + if (newSourceModel) + { connect(sourceModel(), SIGNAL(modelReset()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(layoutChanged()), this, SLOT(sourceReset())); connect(sourceModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)), @@ -1306,7 +1347,8 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, { Q_UNUSED(parent); // Avoid warnings when compiling release Q_ASSERT(!parent.isValid()); - if (start != 0 || start != end) { + if (start != 0 || start != end) + { m_sourceRowCache.clear(); reset(); return; @@ -1315,10 +1357,13 @@ void HistoryTreeModel::sourceRowsInserted(const QModelIndex &parent, int start, m_sourceRowCache.clear(); QModelIndex treeIndex = mapFromSource(sourceModel()->index(start, 0)); QModelIndex treeParent = treeIndex.parent(); - if (rowCount(treeParent) == 1) { + if (rowCount(treeParent) == 1) + { beginInsertRows(QModelIndex(), 0, 0); endInsertRows(); - } else { + } + else + { beginInsertRows(treeParent, treeIndex.row(), treeIndex.row()); endInsertRows(); } @@ -1349,11 +1394,13 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i Q_ASSERT(!parent.isValid()); if (m_sourceRowCache.isEmpty()) return; - for (int i = end; i >= start;) { + for (int i = end; i >= start;) + { QList::iterator it; it = qLowerBound(m_sourceRowCache.begin(), m_sourceRowCache.end(), i); // playing it safe - if (it == m_sourceRowCache.end()) { + if (it == m_sourceRowCache.end()) + { m_sourceRowCache.clear(); reset(); return; @@ -1366,11 +1413,14 @@ void HistoryTreeModel::sourceRowsRemoved(const QModelIndex &parent, int start, i QModelIndex dateParent = index(row, 0); // If we can remove all the rows in the date do that and skip over them int rc = rowCount(dateParent); - if (i - rc + 1 == offset && start <= i - rc + 1) { + if (i - rc + 1 == offset && start <= i - rc + 1) + { beginRemoveRows(QModelIndex(), row, row); m_sourceRowCache.removeAt(row); i -= rc + 1; - } else { + } + else + { beginRemoveRows(dateParent, i - offset, i - offset); ++row; --i; diff --git a/src/history.h b/src/history.h index 4b8773ca..41b4116c 100644 --- a/src/history.h +++ b/src/history.h @@ -49,15 +49,19 @@ public: HistoryItem() {} HistoryItem(const QString &u, const QDateTime &d = QDateTime(), const QString &t = QString()) - : title(t), url(u), dateTime(d) {} + : title(t), url(u), dateTime(d) {} inline bool operator==(const HistoryItem &other) const - { return other.title == title - && other.url == url && other.dateTime == dateTime; } + { + return other.title == title + && other.url == url && other.dateTime == dateTime; + } // history is sorted in reverse inline bool operator <(const HistoryItem &other) const - { return dateTime > other.dateTime; } + { + return dateTime > other.dateTime; + } QString title; QString url; @@ -145,7 +149,8 @@ public slots: void entryUpdated(int offset); public: - enum Roles { + enum Roles + { DateRole = Qt::UserRole + 1, DateTimeRole = Qt::UserRole + 2, UrlRole = Qt::UserRole + 3, @@ -181,7 +186,9 @@ public: HistoryFilterModel(QAbstractItemModel *sourceModel, QObject *parent = 0); inline bool historyContains(const QString &url) const - { load(); return m_historyHash.contains(url); } + { + load(); return m_historyHash.contains(url); + } int historyLocation(const QString &url) const; QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; @@ -191,7 +198,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; - QModelIndex parent(const QModelIndex& index= QModelIndex()) const; + QModelIndex parent(const QModelIndex& index = QModelIndex()) const; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; @@ -257,8 +264,8 @@ signals: void openUrl(const KUrl &url); public: - HistoryMenu(QWidget *parent = 0); - void setInitialActions(QList actions); + HistoryMenu(QWidget *parent = 0); + void setInitialActions(QList actions); protected: bool prePopulated(); @@ -279,7 +286,7 @@ private: /** * Proxy model for the history model that - * exposes each url http://www.foo.com and + * exposes each url http://www.foo.com and * it url starting at the host www.foo.com * */ @@ -296,7 +303,7 @@ public: QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; QModelIndex mapToSource(const QModelIndex &proxyIndex) const; QModelIndex index(int, int, const QModelIndex& = QModelIndex()) const; - QModelIndex parent(const QModelIndex& index= QModelIndex()) const; + QModelIndex parent(const QModelIndex& index = QModelIndex()) const; void setSourceModel(QAbstractItemModel *sourceModel); private slots: @@ -326,7 +333,7 @@ public: QModelIndex mapFromSource(const QModelIndex &sourceIndex) const; QModelIndex mapToSource(const QModelIndex &proxyIndex) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index= QModelIndex()) const; + QModelIndex parent(const QModelIndex &index = QModelIndex()) const; bool hasChildren(const QModelIndex &parent = QModelIndex()) const; Qt::ItemFlags flags(const QModelIndex &index) const; bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); @@ -349,7 +356,7 @@ private: // ----------------------------------------------------------------------------------------------------------------- /** - * A modified QSortFilterProxyModel that always accepts + * A modified QSortFilterProxyModel that always accepts * the root nodes in the tree * so filtering is only done on the children. * Used in the HistoryDialog. diff --git a/src/main.cpp b/src/main.cpp index 71f5792d..9248aa14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,34 +34,34 @@ static const char version[] = "0.0.5"; int main(int argc, char **argv) { - KAboutData about( "rekonq", - 0, - ki18n("rekonq"), - version, - ki18n(description), - KAboutData::License_GPL, - ki18n("(C) 2008 Andrea Diamantini"), - KLocalizedString(), - "http://rekonq.sourceforge.net", - "adjam7@gmail.com" + KAboutData about("rekonq", + 0, + ki18n("rekonq"), + version, + ki18n(description), + KAboutData::License_GPL, + ki18n("(C) 2008 Andrea Diamantini"), + KLocalizedString(), + "http://rekonq.sourceforge.net", + "adjam7@gmail.com" ); - about.addAuthor( ki18n("Andrea Diamantini"), - KLocalizedString(), - "adjam7@gmail.com" + about.addAuthor(ki18n("Andrea Diamantini"), + KLocalizedString(), + "adjam7@gmail.com" ); KCmdLineArgs::init(argc, argv, &about); KCmdLineOptions options; - options.add( "+URL" , ki18n("Location to open") ); - KCmdLineArgs::addCmdLineOptions( options ); + options.add("+URL" , ki18n("Location to open")); + KCmdLineArgs::addCmdLineOptions(options); Application::addCmdLineOptions(); - if (!Application::start()) + if (!Application::start()) { - kWarning() << "rekonq is already running!"; - return 0; + kWarning() << "rekonq is already running!"; + return 0; } Application app; return app.exec(); diff --git a/src/mainview.cpp b/src/mainview.cpp index 7238b966..4ab8dc8b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -52,12 +52,12 @@ MainView::MainView(QWidget *parent) - : KTabWidget(parent) - , m_recentlyClosedTabsAction(0) - , m_recentlyClosedTabsMenu(0) - , m_lineEditCompleter(0) - , m_lineEdits(new QStackedWidget(this)) - , m_tabBar(new TabBar(this)) + : KTabWidget(parent) + , m_recentlyClosedTabsAction(0) + , m_recentlyClosedTabsMenu(0) + , m_lineEditCompleter(0) + , m_lineEdits(new QStackedWidget(this)) + , m_tabBar(new TabBar(this)) { setTabBar(m_tabBar); @@ -86,29 +86,29 @@ MainView::~MainView() { delete m_lineEditCompleter; delete m_recentlyClosedTabsMenu; -} +} void MainView::showTabBar() { bool astb = ReKonfig::alwaysShowTabBar(); - if(astb == true) + if (astb == true) { - if( m_tabBar->isHidden() ) + if (m_tabBar->isHidden()) { m_tabBar->show(); } return; } - if( m_tabBar->count() == 1 ) + if (m_tabBar->count() == 1) { m_tabBar->hide(); } else { - if( m_tabBar->isHidden() ) + if (m_tabBar->isHidden()) { m_tabBar->show(); } @@ -208,7 +208,7 @@ void MainView::clear() // clear the recently closed tabs m_recentlyClosedTabs.clear(); // clear the line edit history - for (int i = 0; i < m_lineEdits->count(); ++i) + for (int i = 0; i < m_lineEdits->count(); ++i) { QLineEdit *qLineEdit = lineEdit(i); qLineEdit->setText(qLineEdit->text()); @@ -252,10 +252,10 @@ void MainView::currentChanged(int index) if (!webView) return; - Q_ASSERT( m_lineEdits->count() == count() ); + Q_ASSERT(m_lineEdits->count() == count()); WebView *oldWebView = this->webView(m_lineEdits->currentIndex()); - if (oldWebView) + if (oldWebView) { disconnect(oldWebView, SIGNAL(statusBarMessage(const QString&)), this, SIGNAL(showStatusBarMessage(const QString&))); disconnect(oldWebView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SIGNAL(linkHovered(const QString&))); @@ -306,14 +306,14 @@ QLineEdit *MainView::lineEdit(int index) const WebView *MainView::webView(int index) const { QWidget *widget = this->widget(index); - if (WebView *webView = qobject_cast(widget)) + if (WebView *webView = qobject_cast(widget)) { return webView; - } - else + } + else { // optimization to delay creating the first webview - if (count() == 1) + if (count() == 1) { MainView *that = const_cast(this); that->setUpdatesEnabled(false); @@ -339,7 +339,7 @@ WebView *MainView::newTab(bool makeCurrent) // line edit UrlBar *urlLineEdit = new UrlBar; QLineEdit *lineEdit = urlLineEdit->lineEdit(); - if (!m_lineEditCompleter && count() > 0) + if (!m_lineEditCompleter && count() > 0) { HistoryCompletionModel *completionModel = new HistoryCompletionModel(this); completionModel->setSourceModel(Application::historyManager()->historyFilterModel()); @@ -358,7 +358,7 @@ WebView *MainView::newTab(bool makeCurrent) m_lineEdits->setSizePolicy(lineEdit->sizePolicy()); // optimization to delay creating the more expensive WebView, history, etc - if (count() == 0) + if (count() == 0) { QWidget *emptyWidget = new QWidget; QPalette p = emptyWidget->palette(); @@ -370,7 +370,7 @@ WebView *MainView::newTab(bool makeCurrent) connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); return 0; } - + // webview WebView *webView = new WebView; urlLineEdit->setWebView(webView); @@ -387,10 +387,10 @@ WebView *MainView::newTab(bool makeCurrent) connect(webView->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SIGNAL(statusBarVisibilityChangeRequested(bool))); connect(webView->page(), SIGNAL(toolBarVisibilityChangeRequested(bool)), this, SIGNAL(toolBarVisibilityChangeRequested(bool))); - connect(webView, SIGNAL( ctrlTabPressed() ), this, SLOT( nextTab() ) ); - connect(webView, SIGNAL( shiftCtrlTabPressed() ), this, SLOT( previousTab() ) ); + connect(webView, SIGNAL(ctrlTabPressed()), this, SLOT(nextTab())); + connect(webView, SIGNAL(shiftCtrlTabPressed()), this, SLOT(previousTab())); - addTab(webView, i18n("(Untitled)") ); + addTab(webView, i18n("(Untitled)")); if (makeCurrent) setCurrentWidget(webView); @@ -406,10 +406,10 @@ WebView *MainView::newTab(bool makeCurrent) void MainView::reloadAllTabs() { - for (int i = 0; i < count(); ++i) + for (int i = 0; i < count(); ++i) { QWidget *tabWidget = widget(i); - if (WebView *tab = qobject_cast(tabWidget)) + if (WebView *tab = qobject_cast(tabWidget)) { tab->reload(); } @@ -419,9 +419,9 @@ void MainView::reloadAllTabs() void MainView::lineEditReturnPressed() { - if (QLineEdit *lineEdit = qobject_cast(sender())) + if (QLineEdit *lineEdit = qobject_cast(sender())) { - emit loadUrlPage( KUrl( lineEdit->text() ) ); + emit loadUrlPage(KUrl(lineEdit->text())); if (m_lineEdits->currentWidget() == lineEdit) { currentWebView()->setFocus(); @@ -435,7 +435,7 @@ void MainView::windowCloseRequested() WebPage *webPage = qobject_cast(sender()); WebView *webView = qobject_cast(webPage->view()); int index = webViewIndex(webView); - if (index >= 0) + if (index >= 0) { if (count() == 1) webView->webPage()->mainWindow()->close(); @@ -466,7 +466,7 @@ void MainView::cloneTab(int index) if (index < 0 || index >= count()) return; WebView *tab = newTab(false); - tab->setUrl( webView(index)->url() ); + tab->setUrl(webView(index)->url()); showTabBar(); } @@ -481,16 +481,16 @@ void MainView::closeTab(int index) return; bool hasFocus = false; - if (WebView *tab = webView(index)) + if (WebView *tab = webView(index)) { - if (tab->isModified()) + if (tab->isModified()) { - int risp = KMessageBox::questionYesNo( this , - i18n("You have modified this page and when closing it you would lose the modification.\n" - "Do you really want to close this page?\n"), - i18n("Do you really want to close this page?"), - KStandardGuiItem::no() ); - if( risp == KMessageBox::No ) + int risp = KMessageBox::questionYesNo(this , + i18n("You have modified this page and when closing it you would lose the modification.\n" + "Do you really want to close this page?\n"), + i18n("Do you really want to close this page?"), + KStandardGuiItem::no()); + if (risp == KMessageBox::No) return; } hasFocus = tab->hasFocus(); @@ -520,9 +520,9 @@ void MainView::webViewLoadStarted() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) + if (-1 != index) { - setTabIcon(index, KIcon("rekonq") ); + setTabIcon(index, KIcon("rekonq")); } } @@ -531,7 +531,7 @@ void MainView::webViewIconChanged() { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) + if (-1 != index) { QIcon icon = Application::instance()->icon(webView->url()); setTabIcon(index, icon); @@ -543,7 +543,8 @@ void MainView::webViewTitleChanged(const QString &title) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { + if (-1 != index) + { setTabText(index, title); } if (currentIndex() == index) @@ -556,7 +557,8 @@ void MainView::webViewUrlChanged(const QUrl &url) { WebView *webView = qobject_cast(sender()); int index = webViewIndex(webView); - if (-1 != index) { + if (-1 != index) + { m_tabBar->setTabData(index, url); } emit tabsChanged(); @@ -566,13 +568,13 @@ void MainView::webViewUrlChanged(const QUrl &url) void MainView::aboutToShowRecentTabsMenu() { m_recentlyClosedTabsMenu->clear(); - for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) + for (int i = 0; i < m_recentlyClosedTabs.count(); ++i) { KAction *action = new KAction(m_recentlyClosedTabsMenu); action->setData(m_recentlyClosedTabs.at(i)); QIcon icon = Application::instance()->icon(m_recentlyClosedTabs.at(i)); action->setIcon(icon); - action->setText( m_recentlyClosedTabs.at(i).prettyUrl() ); + action->setText(m_recentlyClosedTabs.at(i).prettyUrl()); m_recentlyClosedTabsMenu->addAction(action); } } @@ -587,9 +589,9 @@ void MainView::aboutToShowRecentTriggeredAction(QAction *action) void MainView::mouseDoubleClickEvent(QMouseEvent *event) { - if ( !childAt(event->pos() ) - // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) + if (!childAt(event->pos()) + // Remove the line below when QTabWidget does not have a one pixel frame + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { newTab(); return; @@ -600,7 +602,8 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) void MainView::contextMenuEvent(QContextMenuEvent *event) { - if (!childAt(event->pos())) { + if (!childAt(event->pos())) + { m_tabBar->contextMenuRequested(event->pos()); return; } @@ -612,10 +615,10 @@ void MainView::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::MidButton && !childAt(event->pos()) // Remove the line below when QTabWidget does not have a one pixel frame - && event->pos().y() < (tabBar()->y() + tabBar()->height())) + && event->pos().y() < (tabBar()->y() + tabBar()->height())) { - KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { WebView *webView = newTab(); webView->setUrl(url); diff --git a/src/mainview.h b/src/mainview.h index 78fe2a2c..4e2d8b6e 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -87,8 +87,8 @@ public: QLineEdit *lineEdit(int index) const; int webViewIndex(WebView *webView) const; - /** - * show and hide TabBar if user doesn't choose + /** + * show and hide TabBar if user doesn't choose * "Always Show TabBar" option * */ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6f12220f..d76b0d8d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -63,9 +63,9 @@ MainWindow::MainWindow() - : KXmlGuiWindow() - , m_view( new MainView(this) ) - , m_bookmarksProvider( new BookmarksProvider(this) ) + : KXmlGuiWindow() + , m_view(new MainView(this)) + , m_bookmarksProvider(new BookmarksProvider(this)) { // accept dnd setAcceptDrops(true); @@ -81,26 +81,26 @@ MainWindow::MainWindow() // Find Bar m_findBar = new FindBar(this); - connect( m_findBar, SIGNAL( searchString(const QString &) ), this, SLOT( slotFind(const QString &) ) ); + connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); layout->addWidget(m_findBar); centralWidget->setLayout(layout); setCentralWidget(centralWidget); // setting size policies - setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // connect signals and slots - connect(m_view, SIGNAL( loadUrlPage(const KUrl &) ), this, SLOT( loadUrl(const KUrl &) ) ); - connect(m_view, SIGNAL( setCurrentTitle(const QString &)), this, SLOT( slotUpdateWindowTitle(const QString &) ) ); - connect(m_view, SIGNAL( showStatusBarMessage(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_view, SIGNAL( linkHovered(const QString&)), statusBar(), SLOT( showMessage(const QString&) ) ); - connect(m_view, SIGNAL( loadProgress(int)), this, SLOT( slotLoadProgress(int) ) ); - connect(m_view, SIGNAL( geometryChangeRequested(const QRect &)), this, SLOT( geometryChangeRequested(const QRect &) ) ); - connect(m_view, SIGNAL( printRequested(QWebFrame *)), this, SLOT( printRequested(QWebFrame *) ) ); - connect(m_view, SIGNAL( menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT( setVisible(bool) ) ); - connect(m_view, SIGNAL( statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT( setVisible(bool) ) ); - connect(m_view, SIGNAL( lastTabClosed() ), m_view, SLOT(newTab() ) ); + connect(m_view, SIGNAL(loadUrlPage(const KUrl &)), this, SLOT(loadUrl(const KUrl &))); + connect(m_view, SIGNAL(setCurrentTitle(const QString &)), this, SLOT(slotUpdateWindowTitle(const QString &))); + connect(m_view, SIGNAL(showStatusBarMessage(const QString&)), statusBar(), SLOT(showMessage(const QString&))); + connect(m_view, SIGNAL(linkHovered(const QString&)), statusBar(), SLOT(showMessage(const QString&))); + connect(m_view, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int))); + connect(m_view, SIGNAL(geometryChangeRequested(const QRect &)), this, SLOT(geometryChangeRequested(const QRect &))); + connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); + connect(m_view, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); + connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); + connect(m_view, SIGNAL(lastTabClosed()), m_view, SLOT(newTab())); slotUpdateWindowTitle(); @@ -111,10 +111,10 @@ MainWindow::MainWindow() statusBar()->show(); // ----- BOOKMARKS MENU: this has to be done BEFORE setupGUI!! - KAction *a = new KActionMenu( i18n("B&ookmarks"), this ); - actionCollection()->addAction( QLatin1String("bookmarks"), a ); + KAction *a = new KActionMenu(i18n("B&ookmarks"), this); + actionCollection()->addAction(QLatin1String("bookmarks"), a); KMenu *bmMenu = m_bookmarksProvider->bookmarksMenu(); - a->setMenu( bmMenu ); + a->setMenu(bmMenu); // a call to KXmlGuiWindow::setupGUI() populates the GUI // with actions, using KXMLGUI. @@ -130,17 +130,17 @@ MainWindow::MainWindow() setupTabBar(); // setting up custom widgets.. - KToolBar *navigationBar = toolBar( "mainToolBar" ); - navigationBar->addWidget( m_view->lineEditStack() ); + KToolBar *navigationBar = toolBar("mainToolBar"); + navigationBar->addWidget(m_view->lineEditStack()); KToolBar *bmToolbar = toolBar("bookmarksToolBar"); - m_bookmarksProvider->provideBmToolbar( bmToolbar ); + m_bookmarksProvider->provideBmToolbar(bmToolbar); // setting up toolbars to NOT have context menu enabled - setContextMenuPolicy( Qt::DefaultContextMenu ); + setContextMenuPolicy(Qt::DefaultContextMenu); // search bar - m_searchBar = new SearchBar( this ); + m_searchBar = new SearchBar(this); connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); navigationBar->addWidget(m_searchBar); } @@ -165,106 +165,106 @@ void MainWindow::setupActions() KAction *a; // Standard Actions - KStandardAction::openNew(this, SLOT( slotFileNew() ) , actionCollection() ); - KStandardAction::open( this, SLOT( slotFileOpen() ), actionCollection() ); - KStandardAction::saveAs( this, SLOT( slotFileSaveAs() ), actionCollection() ); - KStandardAction::printPreview( this, SLOT( slotFilePrintPreview() ), actionCollection() ); - KStandardAction::print( this, SLOT( slotFilePrint() ), actionCollection() ); - KStandardAction::quit( this , SLOT( close() ), actionCollection() ); - KStandardAction::find(this, SLOT( slotViewFindBar() ) , actionCollection() ); - KStandardAction::findNext(this, SLOT( slotFindNext() ) , actionCollection() ); - KStandardAction::findPrev(this, SLOT( slotFindPrevious() ) , actionCollection() ); - KStandardAction::fullScreen( this, SLOT( slotViewFullScreen(bool) ), this, actionCollection() ); - KStandardAction::home( this, SLOT( slotHome() ), actionCollection() ); - KStandardAction::preferences( this, SLOT( slotPreferences() ), actionCollection() ); + KStandardAction::openNew(this, SLOT(slotFileNew()) , actionCollection()); + KStandardAction::open(this, SLOT(slotFileOpen()), actionCollection()); + KStandardAction::saveAs(this, SLOT(slotFileSaveAs()), actionCollection()); + KStandardAction::printPreview(this, SLOT(slotFilePrintPreview()), actionCollection()); + KStandardAction::print(this, SLOT(slotFilePrint()), actionCollection()); + KStandardAction::quit(this , SLOT(close()), actionCollection()); + KStandardAction::find(this, SLOT(slotViewFindBar()) , actionCollection()); + KStandardAction::findNext(this, SLOT(slotFindNext()) , actionCollection()); + KStandardAction::findPrev(this, SLOT(slotFindPrevious()) , actionCollection()); + KStandardAction::fullScreen(this, SLOT(slotViewFullScreen(bool)), this, actionCollection()); + KStandardAction::home(this, SLOT(slotHome()), actionCollection()); + KStandardAction::preferences(this, SLOT(slotPreferences()), actionCollection()); // WEB Actions (NO KStandardActions..) - KStandardAction::redisplay( m_view, SLOT( slotWebReload() ), actionCollection() ); - KStandardAction::back( m_view, SLOT( slotWebBack() ), actionCollection() ); - KStandardAction::forward( m_view, SLOT( slotWebForward() ), actionCollection() ); - KStandardAction::undo( m_view, SLOT( slotWebUndo() ), actionCollection() ); - KStandardAction::redo( m_view, SLOT( slotWebRedo() ), actionCollection() ); - KStandardAction::cut( m_view, SLOT( slotWebCut() ), actionCollection() ); - KStandardAction::copy( m_view, SLOT( slotWebCopy() ), actionCollection() ); - KStandardAction::paste( m_view, SLOT( slotWebPaste() ), actionCollection() ); - - a = new KAction ( KIcon( "process-stop" ), i18n("&Stop"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Period) ); - actionCollection()->addAction( QLatin1String("stop"), a ); - connect( a, SIGNAL( triggered(bool) ), m_view, SLOT( slotWebStop() ) ); - - // stop reload Action - m_stopReload = new KAction( KIcon("view-refresh"), i18n("reload"), this ); - actionCollection()->addAction( QLatin1String("stop reload") , m_stopReload ); - - // ============== Custom Actions - a = new KAction( KIcon(), i18n("Open Location"), this); - actionCollection()->addAction( QLatin1String("open location"), a ); - connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotOpenLocation() ) ); - - a = new KAction( i18n("Private &Browsing..."), this ); + KStandardAction::redisplay(m_view, SLOT(slotWebReload()), actionCollection()); + KStandardAction::back(m_view, SLOT(slotWebBack()), actionCollection()); + KStandardAction::forward(m_view, SLOT(slotWebForward()), actionCollection()); + KStandardAction::undo(m_view, SLOT(slotWebUndo()), actionCollection()); + KStandardAction::redo(m_view, SLOT(slotWebRedo()), actionCollection()); + KStandardAction::cut(m_view, SLOT(slotWebCut()), actionCollection()); + KStandardAction::copy(m_view, SLOT(slotWebCopy()), actionCollection()); + KStandardAction::paste(m_view, SLOT(slotWebPaste()), actionCollection()); + + a = new KAction(KIcon("process-stop"), i18n("&Stop"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Period)); + actionCollection()->addAction(QLatin1String("stop"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(slotWebStop())); + + // stop reload Action + m_stopReload = new KAction(KIcon("view-refresh"), i18n("reload"), this); + actionCollection()->addAction(QLatin1String("stop reload") , m_stopReload); + + // ============== Custom Actions + a = new KAction(KIcon(), i18n("Open Location"), this); + actionCollection()->addAction(QLatin1String("open location"), a); + connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotOpenLocation())); + + a = new KAction(i18n("Private &Browsing..."), this); a->setCheckable(true); - actionCollection()->addAction( i18n("private browsing"), a ); - connect( a, SIGNAL( triggered(bool) ) , this, SLOT( slotPrivateBrowsing() ) ); + actionCollection()->addAction(i18n("private browsing"), a); + connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotPrivateBrowsing())); - a = new KAction( KIcon("zoom-in"), i18n("&Enlarge Font"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Plus) ); - actionCollection()->addAction( QLatin1String("bigger font"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextBigger() ) ); + a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus)); + actionCollection()->addAction(QLatin1String("bigger font"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextBigger())); - a = new KAction( KIcon("zoom-original"), i18n("&Normal Font"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_0) ); - actionCollection()->addAction( QLatin1String("normal font"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextNormal() ) ); + a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0)); + actionCollection()->addAction(QLatin1String("normal font"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextNormal())); - a = new KAction( KIcon("zoom-out"), i18n("&Shrink Font"), this ); - a->setShortcut( QKeySequence(Qt::CTRL | Qt::Key_Minus) ); - actionCollection()->addAction( QLatin1String("smaller font"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewTextSmaller() ) ); + a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this); + a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus)); + actionCollection()->addAction(QLatin1String("smaller font"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextSmaller())); - a = new KAction( i18n("Page S&ource"), this ); - actionCollection()->addAction( QLatin1String("page source"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotViewPageSource() ) ); + a = new KAction(i18n("Page S&ource"), this); + actionCollection()->addAction(QLatin1String("page source"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewPageSource())); - a = new KAction( KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this ); + a = new KAction(KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this); a->setCheckable(true); - actionCollection()->addAction( QLatin1String("web inspector"), a ); - connect( a, SIGNAL( triggered(bool) ), this, SLOT( slotToggleInspector(bool) ) ); + actionCollection()->addAction(QLatin1String("web inspector"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(slotToggleInspector(bool))); // ================ history related actions - KAction *historyBack = new KAction( KIcon("go-previous"), i18n("Back"), this); + KAction *historyBack = new KAction(KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); historyBack->setMenu(m_historyBackMenu); - connect(historyBack, SIGNAL( triggered(bool) ), this, SLOT( slotOpenPrevious() ) ); + connect(historyBack, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); // FIXME < --------------------------------------------------------------------------------------------------------------------------------------| connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - actionCollection()->addAction( QLatin1String("history back"), historyBack); + actionCollection()->addAction(QLatin1String("history back"), historyBack); - KAction *historyForward = new KAction( KIcon("go-next"), i18n("Forward"), this ); - connect(historyForward, SIGNAL( triggered(bool) ), this, SLOT( slotOpenNext() ) ); - actionCollection()->addAction( QLatin1String("history forward"), historyForward ); + KAction *historyForward = new KAction(KIcon("go-next"), i18n("Forward"), this); + connect(historyForward, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); + actionCollection()->addAction(QLatin1String("history forward"), historyForward); // =================== Tab Actions - a = new KAction( KIcon("tab-new"), i18n("New &Tab"), this); - a->setShortcut( KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T) ); - actionCollection()->addAction( QLatin1String("new tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(newTab())); + a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); + a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T)); + actionCollection()->addAction(QLatin1String("new tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); - a->setShortcut( KShortcut( Qt::CTRL + Qt::Key_W ) ); - actionCollection()->addAction( QLatin1String("close tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(closeTab())); + a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_W)); + actionCollection()->addAction(QLatin1String("close tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(closeTab())); a = new KAction(i18n("Show Next Tab"), this); - a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext() ); - actionCollection()->addAction( QLatin1String("show next tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(nextTab())); + a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); + actionCollection()->addAction(QLatin1String("show next tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); - a->setShortcuts( QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev() ); - actionCollection()->addAction( QLatin1String("show prev tab"), a); - connect(a, SIGNAL( triggered(bool) ), m_view, SLOT(previousTab())); + a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); + actionCollection()->addAction(QLatin1String("show prev tab"), a); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab())); } @@ -272,14 +272,14 @@ void MainWindow::setupTabBar() { // Left corner button QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction( actionCollection()->action("new tab") ); + addTabButton->setDefaultAction(actionCollection()->action("new tab")); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(addTabButton, Qt::TopLeftCorner); // right corner button QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction( actionCollection()->action("close tab") ); + closeTabButton->setDefaultAction(actionCollection()->action("close tab")); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(closeTabButton, Qt::TopRightCorner); @@ -291,13 +291,13 @@ void MainWindow::setupHistoryMenu() HistoryMenu *historyMenu = new HistoryMenu(this); connect(historyMenu, SIGNAL(openUrl(const KUrl&)), m_view, SLOT(loadUrlInCurrentTab(const KUrl&))); connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); - historyMenu->setTitle( i18n("&History") ); - menuBar()->insertMenu( actionCollection()->action("bookmarks"), historyMenu); + historyMenu->setTitle(i18n("&History")); + menuBar()->insertMenu(actionCollection()->action("bookmarks"), historyMenu); QList historyActions; - historyActions.append( actionCollection()->action("history back") ); - historyActions.append( actionCollection()->action("history forward") ); - historyActions.append( m_view->recentlyClosedTabsAction() ); + historyActions.append(actionCollection()->action("history back")); + historyActions.append(actionCollection()->action("history forward")); + historyActions.append(m_view->recentlyClosedTabsAction()); historyMenu->setInitialActions(historyActions); } @@ -308,7 +308,7 @@ void MainWindow::setupHistoryMenu() void MainWindow::slotUpdateConf() { - // ============== General ================== + // ============== General ================== m_homePage = ReKonfig::homePage(); mainView()->showTabBar(); @@ -354,34 +354,34 @@ KUrl MainWindow::guessUrlFromString(const QString &string) // Check if it looks like a qualified URL. Try parsing it and see. bool hasSchema = test.exactMatch(urlStr); - if (hasSchema) + if (hasSchema) { QUrl qurl(urlStr, QUrl::TolerantMode); KUrl url(qurl); - if ( url.isValid() ) + if (url.isValid()) { return url; } } // Might be a file. - if (QFile::exists(urlStr)) + if (QFile::exists(urlStr)) { QFileInfo info(urlStr); - return KUrl::fromPath( info.absoluteFilePath() ); + return KUrl::fromPath(info.absoluteFilePath()); } // Might be a shorturl - try to detect the schema. - if (!hasSchema) + if (!hasSchema) { int dotIndex = urlStr.indexOf(QLatin1Char('.')); - if (dotIndex != -1) + if (dotIndex != -1) { QString prefix = urlStr.left(dotIndex).toLower(); QString schema = (prefix == QLatin1String("ftp")) ? prefix : QLatin1String("http"); QUrl qurl(schema + QLatin1String("://") + urlStr, QUrl::TolerantMode); KUrl url(qurl); - if ( url.isValid() ) + if (url.isValid()) { return url; } @@ -393,7 +393,7 @@ KUrl MainWindow::guessUrlFromString(const QString &string) KUrl url(qurl); // finally for cases where the user just types in a hostname add http - if ( qurl.scheme().isEmpty() ) + if (qurl.scheme().isEmpty()) { qurl = QUrl(QLatin1String("http://") + string, QUrl::TolerantMode); url = KUrl(qurl); @@ -407,7 +407,7 @@ void MainWindow::loadUrl(const KUrl &url) if (!currentTab() || url.isEmpty()) return; - m_view->currentLineEdit()->setText( url.prettyUrl() ); + m_view->currentLineEdit()->setText(url.prettyUrl()); m_view->loadUrlInCurrentTab(url); } @@ -424,7 +424,7 @@ void MainWindow::slotFileSaveAs() KUrl srcUrl = currentTab()->url(); QString destPath = KFileDialog::getSaveFileName(); KUrl destUrl = KUrl(destPath); - Application::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl(srcUrl, destUrl); } @@ -432,7 +432,7 @@ void MainWindow::slotPreferences() { // an instance the dialog could be already created and could be cached, // in which case you want to display the cached dialog - if ( SettingsDialog::showDialog( "rekonfig" ) ) + if (SettingsDialog::showDialog("rekonfig")) return; // we didn't find an instance of this dialog, so lets create it @@ -453,11 +453,11 @@ void MainWindow::slotUpdateStatusbar(const QString &string) void MainWindow::slotUpdateWindowTitle(const QString &title) { - if (title.isEmpty()) + if (title.isEmpty()) { setWindowTitle("rekonq"); - } - else + } + else { setWindowTitle(title + " - rekonq"); } @@ -473,16 +473,16 @@ void MainWindow::slotFileNew() void MainWindow::slotFileOpen() { - QString filePath = KFileDialog::getOpenFileName( KUrl(), - i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), - this, - i18n("Open Web Resource") + QString filePath = KFileDialog::getOpenFileName(KUrl(), + i18n("Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)"), + this, + i18n("Open Web Resource") ); if (filePath.isEmpty()) return; - loadUrl( guessUrlFromString(filePath) ); + loadUrl(guessUrlFromString(filePath)); } @@ -508,8 +508,8 @@ void MainWindow::printRequested(QWebFrame *frame) { QPrinter printer; QPrintDialog *dialog = new QPrintDialog(&printer, this); - dialog->setWindowTitle( i18n("Print Document") ); - if (dialog->exec() != QDialog::Accepted ) + dialog->setWindowTitle(i18n("Print Document")); + if (dialog->exec() != QDialog::Accepted) return; frame->print(&printer); } @@ -519,25 +519,25 @@ void MainWindow::slotPrivateBrowsing() { QWebSettings *settings = QWebSettings::globalSettings(); bool pb = settings->testAttribute(QWebSettings::PrivateBrowsingEnabled); - if (!pb) + if (!pb) { QString title = i18n("Are you sure you want to turn on private browsing?"); QString text = "" + title + i18n("

    When private browsing in turned on," - " webpages are not added to the history," - " items are automatically removed from the Downloads window," \ - " new cookies are not stored, current cookies can't be accessed," \ - " site icons wont be stored, session wont be saved, " \ - " and searches are not addded to the pop-up menu in the Google search box." \ - " Until you close the window, you can still click the Back and Forward buttons" \ - " to return to the webpages you have opened."); - - int button = KMessageBox::questionYesNo( this, text, title ); - if (button == KMessageBox::Ok) + " webpages are not added to the history," + " items are automatically removed from the Downloads window," \ + " new cookies are not stored, current cookies can't be accessed," \ + " site icons wont be stored, session wont be saved, " \ + " and searches are not addded to the pop-up menu in the Google search box." \ + " Until you close the window, you can still click the Back and Forward buttons" \ + " to return to the webpages you have opened."); + + int button = KMessageBox::questionYesNo(this, text, title); + if (button == KMessageBox::Ok) { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); } - } - else + } + else { settings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); @@ -550,13 +550,13 @@ void MainWindow::slotPrivateBrowsing() // void MainWindow::closeEvent(QCloseEvent *event) // { -// if (m_view->count() > 1) +// if (m_view->count() > 1) // { -// int ret = KMessageBox::warningYesNo(this, +// int ret = KMessageBox::warningYesNo(this, // i18n("Are you sure you want to close the window?" " There are %1 tab open" , m_view->count() ), -// i18n("Closing") +// i18n("Closing") // ); -// if (ret == KMessageBox::No) +// if (ret == KMessageBox::No) // { // event->ignore(); // return; @@ -588,7 +588,7 @@ void MainWindow::slotFindNext() return; if (!currentTab()->findText(m_lastSearch, QWebPage::FindWrapsAroundDocument)) { - slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); } } @@ -599,7 +599,7 @@ void MainWindow::slotFindPrevious() return; if (!currentTab()->findText(m_lastSearch, QWebPage::FindBackward)) { - slotUpdateStatusbar( QString(m_lastSearch) + i18n(" not found.") ); + slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); } } @@ -629,9 +629,9 @@ void MainWindow::slotViewTextSmaller() // TODO improve this -void MainWindow::slotViewFullScreen( bool makeFullScreen ) +void MainWindow::slotViewFullScreen(bool makeFullScreen) { - if ( makeFullScreen == true ) + if (makeFullScreen == true) { menuBar()->hide(); toolBar("mainToolBar")->hide(); @@ -641,7 +641,7 @@ void MainWindow::slotViewFullScreen( bool makeFullScreen ) menuBar()->show(); toolBar("mainToolBar")->show(); } - KToggleFullScreenAction::setFullScreen( this, makeFullScreen ); + KToggleFullScreenAction::setFullScreen(this, makeFullScreen); } @@ -652,7 +652,7 @@ void MainWindow::slotViewPageSource() QString markup = currentTab()->page()->mainFrame()->toHtml(); QPlainTextEdit *view = new QPlainTextEdit(markup); - view->setWindowTitle( i18n("Page Source of ") + currentTab()->title() ); + view->setWindowTitle(i18n("Page Source of ") + currentTab()->title()); view->setMinimumWidth(640); view->setAttribute(Qt::WA_DeleteOnClose); view->show(); @@ -661,20 +661,20 @@ void MainWindow::slotViewPageSource() void MainWindow::slotHome() { - loadUrl( KUrl(m_homePage) ); + loadUrl(KUrl(m_homePage)); } void MainWindow::slotToggleInspector(bool enable) { QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, enable); - if (enable) + if (enable) { - int result = KMessageBox::questionYesNo(this, - i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" - "Do you want to reload all pages?"), - i18n("Web Inspector") ); - if (result == KMessageBox::Yes) + int result = KMessageBox::questionYesNo(this, + i18n("The web inspector will only work correctly for pages that were loaded after enabling.\n" + "Do you want to reload all pages?"), + i18n("Web Inspector")); + if (result == KMessageBox::Yes) { m_view->reloadAllTabs(); } @@ -711,23 +711,23 @@ WebView *MainWindow::currentTab() const // FIXME: this actually doesn't work properly.. void MainWindow::slotLoadProgress(int progress) { - QAction *stop = actionCollection()->action( "stop" ); - QAction *reload = actionCollection()->action( "view_redisplay" ); - if (progress < 100 && progress > 0) + QAction *stop = actionCollection()->action("stop"); + QAction *reload = actionCollection()->action("view_redisplay"); + if (progress < 100 && progress > 0) { - disconnect( m_stopReload, SIGNAL( triggered( bool ) ), reload , SIGNAL( triggered(bool) ) ); - m_stopReload->setIcon( KIcon( "process-stop" ) ); - m_stopReload->setToolTip( i18n("Stop loading the current page") ); - m_stopReload->setText( i18n("Stop") ); - connect(m_stopReload, SIGNAL( triggered(bool ) ), stop, SIGNAL( triggered(bool) ) ); - } - else + disconnect(m_stopReload, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); + m_stopReload->setIcon(KIcon("process-stop")); + m_stopReload->setToolTip(i18n("Stop loading the current page")); + m_stopReload->setText(i18n("Stop")); + connect(m_stopReload, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); + } + else { - disconnect( m_stopReload, SIGNAL( triggered( bool ) ), stop , SIGNAL( triggered(bool ) ) ); - m_stopReload->setIcon( KIcon( "view-refresh" ) ); - m_stopReload->setToolTip( i18n("Reload the current page") ); - m_stopReload->setText( i18n("Reload") ); - connect(m_stopReload, SIGNAL( triggered( bool ) ), reload, SIGNAL( triggered(bool) ) ); + disconnect(m_stopReload, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); + m_stopReload->setIcon(KIcon("view-refresh")); + m_stopReload->setToolTip(i18n("Reload the current page")); + m_stopReload->setText(i18n("Reload")); + connect(m_stopReload, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); } } @@ -740,11 +740,11 @@ void MainWindow::slotAboutToShowBackMenu() return; QWebHistory *history = currentTab()->history(); int historyCount = history->count(); - for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) + for (int i = history->backItems(historyCount).count() - 1; i >= 0; --i) { QWebHistoryItem item = history->backItems(history->count()).at(i); KAction *action = new KAction(this); - action->setData(-1*(historyCount-i-1)); + action->setData(-1*(historyCount - i - 1)); QIcon icon = Application::instance()->icon(item.url()); action->setIcon(icon); action->setText(item.title()); @@ -761,7 +761,7 @@ void MainWindow::slotOpenActionUrl(QAction *action) { history->goToItem(history->backItems(-1*offset).first()); // back } - else + else { if (offset > 0) { @@ -774,16 +774,16 @@ void MainWindow::slotOpenActionUrl(QAction *action) void MainWindow::slotOpenPrevious() { QWebHistory *history = currentTab()->history(); - if ( history->canGoBack() ) - history->goToItem( history->backItem() ); + if (history->canGoBack()) + history->goToItem(history->backItem()); } void MainWindow::slotOpenNext() { QWebHistory *history = currentTab()->history(); - if ( history->canGoForward() ) - history->goToItem( history->forwardItem() ); + if (history->canGoForward()) + history->goToItem(history->forwardItem()); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 15eda7ec..220fceca 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,11 +43,11 @@ class WebView; /** - * This class serves as the main window for rekonq. + * This class serves as the main window for rekonq. * It handles the menus, toolbars, and status bars. * */ -class MainWindow : public KXmlGuiWindow +class MainWindow : public KXmlGuiWindow { Q_OBJECT diff --git a/src/modelmenu.cpp b/src/modelmenu.cpp index 3ed5b9ac..fae8acab 100644 --- a/src/modelmenu.cpp +++ b/src/modelmenu.cpp @@ -23,13 +23,13 @@ ModelMenu::ModelMenu(QWidget * parent) - : KMenu(parent) - , m_maxRows(7) - , m_firstSeparator(-1) - , m_maxWidth(-1) - , m_hoverRole(0) - , m_separatorRole(0) - , m_model(0) + : KMenu(parent) + , m_maxRows(7) + , m_firstSeparator(-1) + , m_maxWidth(-1) + , m_hoverRole(0) + , m_separatorRole(0) + , m_model(0) { connect(this, SIGNAL(aboutToShow()), this, SLOT(aboutToShow())); } @@ -121,10 +121,10 @@ int ModelMenu::separatorRole() const Q_DECLARE_METATYPE(QModelIndex) void ModelMenu::aboutToShow() { - if (QMenu *menu = qobject_cast(sender())) + if (QMenu *menu = qobject_cast(sender())) { QVariant v = menu->menuAction()->data(); - if (v.canConvert()) + if (v.canConvert()) { QModelIndex idx = qvariant_cast(v); createMenu(idx, -1, menu, menu); @@ -145,7 +145,7 @@ void ModelMenu::aboutToShow() void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu, QMenu *menu) { - if (!menu) + if (!menu) { QString title = parent.data().toString(); menu = new QMenu(title, this); @@ -163,16 +163,20 @@ void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu if (max != -1) end = qMin(max, end); - connect(menu, SIGNAL( triggered(QAction*) ), this, SLOT( triggered(QAction*) ) ); - connect(menu, SIGNAL( hovered(QAction*) ), this, SLOT( hovered(QAction*) ) ); + connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(triggered(QAction*))); + connect(menu, SIGNAL(hovered(QAction*)), this, SLOT(hovered(QAction*))); - for (int i = 0; i < end; ++i) { + for (int i = 0; i < end; ++i) + { QModelIndex idx = m_model->index(i, 0, parent); - if (m_model->hasChildren(idx)) { + if (m_model->hasChildren(idx)) + { createMenu(idx, -1, menu); - } else { + } + else + { if (m_separatorRole != 0 - && idx.data(m_separatorRole).toBool()) + && idx.data(m_separatorRole).toBool()) addSeparator(); else menu->addAction(makeAction(idx)); @@ -184,7 +188,7 @@ void ModelMenu::createMenu(const QModelIndex &parent, int max, QMenu *parentMenu KAction *ModelMenu::makeAction(const QModelIndex &index) { - QIcon icon = qvariant_cast( index.data(Qt::DecorationRole) ); + QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); KAction *action = (KAction *) makeAction(KIcon(icon), index.data().toString(), this); QVariant v; v.setValue(index); @@ -204,7 +208,7 @@ KAction *ModelMenu::makeAction(const KIcon &icon, const QString &text, QObject * void ModelMenu::triggered(QAction *action) { QVariant v = action->data(); - if (v.canConvert()) + if (v.canConvert()) { QModelIndex idx = qvariant_cast(v); emit activated(idx); @@ -214,7 +218,7 @@ void ModelMenu::triggered(QAction *action) void ModelMenu::hovered(QAction *action) { QVariant v = action->data(); - if (v.canConvert()) + if (v.canConvert()) { QModelIndex idx = qvariant_cast(v); QString hoveredString = idx.data(m_hoverRole).toString(); diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 1c426c61..c0b05e6a 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -49,10 +49,10 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) - : QNetworkAccessManager(parent) + : QNetworkAccessManager(parent) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), - SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); + SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); @@ -66,11 +66,11 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) #if QT_VERSION >= 0x040500 QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); - QString location = KStandardDirs::locateLocal("cache","",true); + QString location = KStandardDirs::locateLocal("cache", "", true); diskCache->setCacheDirectory(location); setCache(diskCache); -#endif +#endif } @@ -79,9 +79,9 @@ void NetworkAccessManager::loadSettings() { kWarning() << "loading NetworkAccessManager settings.."; QNetworkProxy proxy; - if ( ReKonfig::isProxyEnabled() ) + if (ReKonfig::isProxyEnabled()) { - if ( ReKonfig::proxyType() == 0 ) + if (ReKonfig::proxyType() == 0) { proxy.setType(QNetworkProxy::Socks5Proxy); } @@ -89,10 +89,10 @@ void NetworkAccessManager::loadSettings() { proxy.setType(QNetworkProxy::HttpProxy); } - proxy.setHostName( ReKonfig::proxyHostName() ); - proxy.setPort( ReKonfig::proxyPort() ); - proxy.setUser( ReKonfig::proxyUserName() ); - proxy.setPassword( ReKonfig::proxyPassword() ); + proxy.setHostName(ReKonfig::proxyHostName()); + proxy.setPort(ReKonfig::proxyPort()); + proxy.setUser(ReKonfig::proxyUserName()); + proxy.setPassword(ReKonfig::proxyPassword()); } setProxy(proxy); } @@ -112,12 +112,12 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent passwordDialog.iconLabel->setText(QString()); passwordDialog.iconLabel->setPixmap(mainWindow->style()->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mainWindow).pixmap(32, 32)); - QString introMessage = i18n("Enter username and password for ") + - Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + ""; + QString introMessage = i18n("Enter username and password for ") + + Qt::escape(reply->url().toString()) + i18n(" at ") + Qt::escape(reply->url().toString()) + ""; passwordDialog.introLabel->setText(introMessage); passwordDialog.introLabel->setWordWrap(true); - if (dialog.exec() == QDialog::Accepted) + if (dialog.exec() == QDialog::Accepted) { auth->setUser(passwordDialog.userNameLineEdit->text()); auth->setPassword(passwordDialog.passwordLineEdit->text()); @@ -141,7 +141,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox proxyDialog.introLabel->setText(introMessage); proxyDialog.introLabel->setWordWrap(true); - if (dialog.exec() == QDialog::Accepted) + if (dialog.exec() == QDialog::Accepted) { auth->setUser(proxyDialog.userNameLineEdit->text()); auth->setPassword(proxyDialog.passwordLineEdit->text()); @@ -157,7 +157,7 @@ void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QListurl().toString() + "\n\n" + QString(errors) + "\n\n"); + int ret = KMessageBox::warningYesNo(mainWindow, i18n("SSL Errors:\n\n") + reply->url().toString() + "\n\n" + QString(errors) + "\n\n"); if (ret == KMessageBox::Yes) reply->ignoreSslErrors(); } diff --git a/src/searchbar.cpp b/src/searchbar.cpp index 80b231ac..0d318edb 100644 --- a/src/searchbar.cpp +++ b/src/searchbar.cpp @@ -36,23 +36,23 @@ #include -SearchBar::SearchBar(QWidget *parent) : - KLineEdit(parent) +SearchBar::SearchBar(QWidget *parent) : + KLineEdit(parent) { setMinimumWidth(180); kWarning() << "setting fixed minimum width.." ; - setFocusPolicy( Qt::WheelFocus ); - setMouseTracking( true ); + setFocusPolicy(Qt::WheelFocus); + setMouseTracking(true); setAcceptDrops(true); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); - setClearButtonShown( true ); + setClearButtonShown(true); // better solution than using QPalette(s).. - setClickMessage( i18n("Search..") ); + setClickMessage(i18n("Search..")); // setting QNetworkAccessManager.. netMan = new QNetworkAccessManager(this); @@ -64,7 +64,7 @@ SearchBar::SearchBar(QWidget *parent) : connect(timer, SIGNAL(timeout()), SLOT(autoSuggest())); connect(this, SIGNAL(textEdited(QString)), timer, SLOT(start())); - connect(this, SIGNAL( returnPressed() ) , this , SLOT( searchNow() ) ); + connect(this, SIGNAL(returnPressed()) , this , SLOT(searchNow())); } @@ -92,8 +92,8 @@ void SearchBar::focusInEvent(QFocusEvent *event) KLineEdit::focusInEvent(event); QPalette p; - p.setColor( QPalette::Text , Qt::black ); - setPalette( p ); + p.setColor(QPalette::Text , Qt::black); + setPalette(p); clear(); } @@ -109,7 +109,7 @@ void SearchBar::autoSuggest() void SearchBar::handleNetworkData(QNetworkReply *networkReply) { QUrl url = networkReply->url(); - if (!networkReply->error()) + if (!networkReply->error()) { QStringList choices; diff --git a/src/searchbar.h b/src/searchbar.h index 5ec81885..39e66952 100644 --- a/src/searchbar.h +++ b/src/searchbar.h @@ -33,7 +33,7 @@ class QNetworkAccessManager; class QNetworkReply; /** - * This class defines an internet search bar. + * This class defines an internet search bar. */ class SearchBar : public KLineEdit { @@ -46,7 +46,7 @@ public: public slots: void autoSuggest(); void handleNetworkData(QNetworkReply *networkReply); - + /** * Use this slot to perform one search in one search engine * @@ -54,7 +54,7 @@ public slots: void searchNow(); protected: - void focusInEvent(QFocusEvent * ); + void focusInEvent(QFocusEvent *); signals: void search(const KUrl &url); diff --git a/src/settings.cpp b/src/settings.cpp index 860e7050..8f3d61a0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -63,7 +63,7 @@ private: Private(SettingsDialog *parent); -friend class SettingsDialog; + friend class SettingsDialog; }; @@ -73,47 +73,47 @@ Private::Private(SettingsDialog *parent) KPageWidgetItem *pageItem; widget = new QWidget; - generalUi.setupUi( widget ); + generalUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("General") ); - pageItem->setIcon( KIcon("rekonq") ); + pageItem = parent->addPage(widget , i18n("General")); + pageItem->setIcon(KIcon("rekonq")); widget = new QWidget; - fontsUi.setupUi( widget ); + fontsUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("Fonts") ); - pageItem->setIcon( KIcon("preferences-desktop-font") ); + pageItem = parent->addPage(widget , i18n("Fonts")); + pageItem->setIcon(KIcon("preferences-desktop-font")); widget = new QWidget; - privacyUi.setupUi( widget ); + privacyUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("Privacy") ); - pageItem->setIcon( KIcon("preferences-desktop-personal") ); + pageItem = parent->addPage(widget , i18n("Privacy")); + pageItem->setIcon(KIcon("preferences-desktop-personal")); widget = new QWidget; - proxyUi.setupUi( widget ); + proxyUi.setupUi(widget); widget->layout()->setMargin(0); - pageItem = parent->addPage( widget , i18n("Proxy") ); - pageItem->setIcon( KIcon("preferences-system-network") ); + pageItem = parent->addPage(widget , i18n("Proxy")); + pageItem->setIcon(KIcon("preferences-system-network")); } // ----------------------------------------------------------------------------------------------------- SettingsDialog::SettingsDialog(QWidget *parent) - : KConfigDialog(parent, "rekonfig", ReKonfig::self()) - , d(new Private(this)) + : KConfigDialog(parent, "rekonfig", ReKonfig::self()) + , d(new Private(this)) { setFaceType(KPageDialog::List); showButtonSeparator(true); - setWindowTitle( i18n("rekonfig..") ); + setWindowTitle(i18n("rekonfig..")); setModal(true); readConfig(); - connect( d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT( setHomeToCurrentPage() ) ); - connect( d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT( showExceptions() ) ); - connect( d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT( showCookies() ) ); + connect(d->generalUi.setHomeToCurrentPageButton, SIGNAL(clicked()), this, SLOT(setHomeToCurrentPage())); + connect(d->privacyUi.exceptionsButton, SIGNAL(clicked()), this, SLOT(showExceptions())); + connect(d->privacyUi.cookiesButton, SIGNAL(clicked()), this, SLOT(showCookies())); } @@ -129,13 +129,13 @@ void SettingsDialog::readConfig() { // ======= General d->generalUi.downloadDirUrlRequester->setMode(KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly); - d->generalUi.downloadDirUrlRequester->setUrl( ReKonfig::downloadDir() ); - connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)),this, SLOT(saveSettings())); + d->generalUi.downloadDirUrlRequester->setUrl(ReKonfig::downloadDir()); + connect(d->generalUi.downloadDirUrlRequester, SIGNAL(textChanged(QString)), this, SLOT(saveSettings())); // ======= Fonts // QFont stdFont = ReKonfig::standardFont(); // d->fontsUi.standardFont->setCurrentFont(stdFont); -// +// // QFont fxFont = ReKonfig::fixedFont(); d->fontsUi.kcfg_fixedFont->setOnlyFixed(true); // d->fontsUi.fixedFont->setCurrentFont(fxFont); @@ -151,7 +151,7 @@ void SettingsDialog::readConfig() void SettingsDialog::saveSettings() { // General - ReKonfig::setDownloadDir( d->generalUi.downloadDirUrlRequester->url().prettyUrl() ); + ReKonfig::setDownloadDir(d->generalUi.downloadDirUrlRequester->url().prettyUrl()); // Fonts // ReKonfig::setStandardFont( d->fontsUi.standardFont->currentFont() ); @@ -185,6 +185,6 @@ void SettingsDialog::setHomeToCurrentPage() WebView *webView = mw->currentTab(); if (webView) { - d->generalUi.kcfg_homePage->setText( webView->url().prettyUrl() ); + d->generalUi.kcfg_homePage->setText(webView->url().prettyUrl()); } } diff --git a/src/settings.h b/src/settings.h index 3bf099b4..3d781c20 100644 --- a/src/settings.h +++ b/src/settings.h @@ -40,7 +40,7 @@ public: private: Private* const d; - + private slots: void readConfig(); void saveSettings(); diff --git a/src/tabbar.cpp b/src/tabbar.cpp index d00a95ce..43940f7d 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -42,8 +42,8 @@ TabBar::TabBar(QWidget *parent) - : KTabBar(parent) - , m_parent(parent) + : KTabBar(parent) + , m_parent(parent) { setElideMode(Qt::ElideRight); setContextMenuPolicy(Qt::CustomContextMenu); @@ -53,7 +53,7 @@ TabBar::TabBar(QWidget *parent) QFont standardFont = KGlobalSettings::generalFont(); QString fontFamily = standardFont.family(); int dim = standardFont.pointSize(); - setFont( QFont(fontFamily, dim-1) ); + setFont(QFont(fontFamily, dim - 1)); } @@ -62,12 +62,12 @@ TabBar::~TabBar() } -QSize TabBar::tabSizeHint (int index) const +QSize TabBar::tabSizeHint(int index) const { Q_UNUSED(index); QSize s = m_parent->sizeHint(); int w; - if ( count() > 3 ) + if (count() > 3) { w = s.width() / 4; } @@ -77,7 +77,7 @@ QSize TabBar::tabSizeHint (int index) const } int h = KTabBar::tabSizeHint(index).height(); - QSize ts = QSize(w,h); + QSize ts = QSize(w, h); return ts; } @@ -98,20 +98,20 @@ void TabBar::contextMenuRequested(const QPoint &position) { // FIXME: use right actions KMenu menu; - menu.addAction(i18n("New &Tab"), this, SIGNAL( newTab() ), QKeySequence::AddTab); + menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); if (-1 != index) { m_actualIndex = index; - KAction *action = (KAction * ) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); + KAction *action = (KAction *) menu.addAction(i18n("Clone Tab"), this, SLOT(cloneTab())); menu.addSeparator(); - action = (KAction * ) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); - action = (KAction * ) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); + action = (KAction *) menu.addAction(i18n("&Close Tab"), this, SLOT(closeTab()), QKeySequence::Close); + action = (KAction *) menu.addAction(i18n("Close &Other Tabs"), this, SLOT(closeOtherTabs())); menu.addSeparator(); - action = (KAction * ) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); - } - else + action = (KAction *) menu.addAction(i18n("Reload Tab"), this, SLOT(reloadTab()), QKeySequence::Refresh); + } + else { menu.addSeparator(); } diff --git a/src/tabbar.h b/src/tabbar.h index a265d85c..ad7a376d 100644 --- a/src/tabbar.h +++ b/src/tabbar.h @@ -31,7 +31,7 @@ #include /** - * Tab bar with a few more features such as + * Tab bar with a few more features such as * a context menu and shortcuts * */ @@ -64,7 +64,7 @@ protected: * Added to fix tab dimension * */ - virtual QSize tabSizeHint (int index) const; + virtual QSize tabSizeHint(int index) const; private slots: void selectTabAction(); diff --git a/src/urlbar.cpp b/src/urlbar.cpp index 37c18636..0c904e45 100644 --- a/src/urlbar.cpp +++ b/src/urlbar.cpp @@ -33,19 +33,19 @@ UrlBar::UrlBar(QWidget *parent) - : KHistoryComboBox( true, parent ) - , m_webView(0) - , m_lineEdit(new QLineEdit) + : KHistoryComboBox(true, parent) + , m_webView(0) + , m_lineEdit(new QLineEdit) { - setLineEdit( m_lineEdit ); + setLineEdit(m_lineEdit); QSizePolicy policy = sizePolicy(); setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy()); - m_defaultBaseColor = palette().color( QPalette::Base ); + m_defaultBaseColor = palette().color(QPalette::Base); // add every item to history - connect( this, SIGNAL( activated( const QString& ) ), this, SLOT( addToHistory( const QString& ) ) ); + connect(this, SIGNAL(activated(const QString&)), this, SLOT(addToHistory(const QString&))); webViewIconChanged(); } @@ -91,10 +91,10 @@ void UrlBar::webViewIconChanged() QIcon icon = Application::instance()->icon(url); QPixmap pixmap(icon.pixmap(16, 16)); QIcon urlIcon = QIcon(pixmap); - + // FIXME simple hack to show Icon in the urlbar, as calling changeUrl() doesn't affect it - insertUrl(0,urlIcon,url); - if(count()>1) + insertUrl(0, urlIcon, url); + if (count() > 1) { removeItem(1); } @@ -116,18 +116,18 @@ QLinearGradient UrlBar::generateGradient(const QColor &color) const // void UrlBar::paintEvent( QPaintEvent *event ) // { // QPalette p = palette(); -// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) +// if (m_webView && m_webView->url().scheme() == QLatin1String("https")) // { // QColor lightYellow(248, 248, 210); // p.setBrush(QPalette::Base, generateGradient(lightYellow)); -// } -// else +// } +// else // { // p.setBrush(QPalette::Base, m_defaultBaseColor); // } // setPalette(p); // KHistoryComboBox::paintEvent(event); -// +// // QPainter painter( this ); // QRect backgroundRect = m_lineEdit->frameGeometry(); // contentsRect(); // FIXME perhaps better working with contentsRect // if ( m_webView && !hasFocus() ) // and modifying colours.. diff --git a/src/urlbar.h b/src/urlbar.h index 72c0bd52..cd6477c4 100644 --- a/src/urlbar.h +++ b/src/urlbar.h @@ -37,7 +37,7 @@ class QColor; class UrlBar : public KHistoryComboBox { -Q_OBJECT + Q_OBJECT public: UrlBar(QWidget *parent = 0); diff --git a/src/webview.cpp b/src/webview.cpp index 947b08cd..239a5f5a 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -46,12 +46,12 @@ WebPage::WebPage(QObject *parent) - : QWebPage(parent) - , m_keyboardModifiers(Qt::NoModifier) - , m_pressedButtons(Qt::NoButton) - , m_openInNewTab(false) + : QWebPage(parent) + , m_keyboardModifiers(Qt::NoModifier) + , m_pressedButtons(Qt::NoButton) + , m_openInNewTab(false) { - setNetworkAccessManager( Application::networkAccessManager() ); + setNetworkAccessManager(Application::networkAccessManager()); connect(this, SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(handleUnsupportedContent(QNetworkReply *))); } @@ -65,7 +65,7 @@ WebPage::~WebPage() MainWindow *WebPage::mainWindow() { QObject *w = this->parent(); - while (w) + while (w) { if (MainWindow *mw = qobject_cast(w)) return mw; @@ -81,8 +81,8 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r // ctrl open in new tab and select // ctrl-alt open in new window - if ( type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton) ) + if (type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier + || m_pressedButtons == Qt::MidButton)) { WebView *webView = Application::instance()->newTab(); webView->setFocus(); @@ -91,7 +91,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r m_pressedButtons = Qt::NoButton; return false; } - if ( frame == mainFrame() ) + if (frame == mainFrame()) { m_loadingUrl = request.url(); emit loadingUrl(m_loadingUrl); @@ -108,7 +108,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) { // added to manage web modal dialogs - if(type == QWebPage::WebModalDialog) + if (type == QWebPage::WebModalDialog) { WebView *w = new WebView; return w->page(); @@ -118,8 +118,8 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) { m_openInNewTab = true; } - - if (m_openInNewTab) + + if (m_openInNewTab) { m_openInNewTab = false; return mainWindow()->mainView()->newTab()->page(); @@ -145,45 +145,45 @@ QObject *WebPage::createPlugin(const QString &classId, const QUrl &url, const QS void WebPage::handleUnsupportedContent(QNetworkReply *reply) { - if (reply->error() == QNetworkReply::NoError) + if (reply->error() == QNetworkReply::NoError) { KUrl srcUrl = reply->url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); KUrl destUrl = KUrl(path); - Application::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl(srcUrl, destUrl); return; } QString myfilestr = KStandardDirs::locate("data", "rekonq/htmls/notfound.html"); - QFile file( myfilestr ); + QFile file(myfilestr); bool isOpened = file.open(QIODevice::ReadOnly); Q_ASSERT(isOpened); QString title = i18n("Error loading page: ") + reply->url().toString(); - QString imagePath = KIconLoader::global()->iconPath( "rekonq", KIconLoader::NoGroup, false); + QString imagePath = KIconLoader::global()->iconPath("rekonq", KIconLoader::NoGroup, false); QString html = QString(QLatin1String(file.readAll())) - .arg(title) - .arg("file://" + imagePath) - .arg(reply->errorString()) - .arg(reply->url().toString()); + .arg(title) + .arg("file://" + imagePath) + .arg(reply->errorString()) + .arg(reply->url().toString()); QList frames; frames.append(mainFrame()); - while (!frames.isEmpty()) + while (!frames.isEmpty()) { QWebFrame *frame = frames.takeFirst(); - if (frame->url() == reply->url()) + if (frame->url() == reply->url()) { frame->setHtml(html, reply->url()); return; } QList children = frame->childFrames(); foreach(QWebFrame *frame, children) - frames.append(frame); + frames.append(frame); } - if (m_loadingUrl == reply->url()) + if (m_loadingUrl == reply->url()) { mainFrame()->setHtml(html, reply->url()); } @@ -194,9 +194,9 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply) WebView::WebView(QWidget* parent) - : QWebView(parent) - , m_progress(0) - , m_page(new WebPage(this)) + : QWebView(parent) + , m_progress(0) + , m_page(new WebPage(this)) { setPage(m_page); connect(page(), SIGNAL(statusBarMessage(const QString&)), this, SLOT(setStatusBarText(const QString&))); @@ -214,18 +214,18 @@ WebView::WebView(QWidget* parent) void WebView::contextMenuEvent(QContextMenuEvent *event) { QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); - if (!r.linkUrl().isEmpty()) + if (!r.linkUrl().isEmpty()) { KMenu menu(this); - KAction *a = new KAction( KIcon("tab-new"), i18n("Open in New Tab"), this); - connect( a, SIGNAL( triggered() ), this , SLOT( openLinkInNewTab() ) ); + KAction *a = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this); + connect(a, SIGNAL(triggered()), this , SLOT(openLinkInNewTab())); menu.addAction(a); menu.addSeparator(); - menu.addAction( pageAction(QWebPage::DownloadLinkToDisk) ); + menu.addAction(pageAction(QWebPage::DownloadLinkToDisk)); // Add link to bookmarks... menu.addSeparator(); - menu.addAction( pageAction(QWebPage::CopyLinkToClipboard) ); - if ( page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled) ) + menu.addAction(pageAction(QWebPage::CopyLinkToClipboard)); + if (page()->settings()->testAttribute(QWebSettings::DeveloperExtrasEnabled)) { menu.addAction(pageAction(QWebPage::InspectElement)); } @@ -238,7 +238,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) void WebView::wheelEvent(QWheelEvent *event) { - if (QApplication::keyboardModifiers() & Qt::ControlModifier) + if (QApplication::keyboardModifiers() & Qt::ControlModifier) { int numDegrees = event->delta() / 8; int numSteps = numDegrees / 15; @@ -265,10 +265,10 @@ void WebView::setProgress(int progress) void WebView::loadFinished() { - if (m_progress != 100) + if (m_progress != 100) { kWarning() << "Recieved finished signal while progress is still:" << progress() - << "Url:" << url(); + << "Url:" << url(); } m_progress = 0; } @@ -279,12 +279,12 @@ void WebView::loadUrl(const KUrl &url) { m_initialUrl = url; - if( m_initialUrl.isRelative() ) + if (m_initialUrl.isRelative()) { kWarning() << "1: " << m_initialUrl.url(); - QString fn = m_initialUrl.url( KUrl::RemoveTrailingSlash ); + QString fn = m_initialUrl.url(KUrl::RemoveTrailingSlash); kWarning() << "2: " << fn; - m_initialUrl.setUrl( "//" + fn ); + m_initialUrl.setUrl("//" + fn); m_initialUrl.setScheme("http"); kWarning() << "3: " << m_initialUrl.url(); } @@ -302,7 +302,7 @@ QString WebView::lastStatusBarText() const KUrl WebView::url() const { KUrl url = QWebView::url(); - if ( !url.isEmpty() ) + if (!url.isEmpty()) { return url; } @@ -321,10 +321,10 @@ void WebView::mousePressEvent(QMouseEvent *event) void WebView::mouseReleaseEvent(QMouseEvent *event) { QWebView::mouseReleaseEvent(event); - if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) + if (!event->isAccepted() && (m_page->m_pressedButtons & Qt::MidButton)) { - KUrl url( QApplication::clipboard()->text(QClipboard::Selection) ); - if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) + KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); + if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { setUrl(url); } @@ -343,24 +343,24 @@ void WebView::downloadRequested(const QNetworkRequest &request) KUrl srcUrl = request.url(); QString path = ReKonfig::downloadDir() + QString("/") + srcUrl.fileName(); KUrl destUrl = KUrl(path); - Application::instance()->downloadUrl( srcUrl, destUrl ); + Application::instance()->downloadUrl(srcUrl, destUrl); } void WebView::keyPressEvent(QKeyEvent *event) { - if ( (event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab) ) + if ((event->modifiers() == Qt::ControlModifier) && (event->key() == Qt::Key_Tab)) { emit ctrlTabPressed(); return; } - if( (event->modifiers() == Qt::ControlModifier + Qt::ShiftModifier) && (event->key() == Qt::Key_Backtab) ) + if ((event->modifiers() == Qt::ControlModifier + Qt::ShiftModifier) && (event->key() == Qt::Key_Backtab)) { emit shiftCtrlTabPressed(); return; } - QWebView::keyPressEvent( event ); + QWebView::keyPressEvent(event); } diff --git a/src/webview.h b/src/webview.h index a7832cef..de2822b9 100644 --- a/src/webview.h +++ b/src/webview.h @@ -39,7 +39,7 @@ class QNetworkReply; class QSslError; -class WebPage : public QWebPage +class WebPage : public QWebPage { Q_OBJECT @@ -77,19 +77,25 @@ private: #include -class WebView : public QWebView +class WebView : public QWebView { Q_OBJECT public: WebView(QWidget *parent = 0); - WebPage *webPage() const { return m_page; } + WebPage *webPage() const + { + return m_page; + } void loadUrl(const KUrl &url); KUrl url() const; QString lastStatusBarText() const; - inline int progress() const { return m_progress; } + inline int progress() const + { + return m_progress; + } signals: // switching tabs @@ -102,9 +108,9 @@ protected: void contextMenuEvent(QContextMenuEvent *event); void wheelEvent(QWheelEvent *event); - /** + /** * Filters (SHIFT + ) CTRL + TAB events and emit (shift)ctrlTabPressed() - * to make switch tab + * to make switch tab */ void keyPressEvent(QKeyEvent *event); -- cgit v1.2.1 From 651f97d0652e90ab1af4e80418f42468cc5932e2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 28 Mar 2009 23:46:38 +0100 Subject: pedantic --- data/rekonq.desktop | 2 +- scripts/codingstyle.sh | 25 +++++++++--- src/main.cpp | 2 +- src/mainwindow.cpp | 90 ++++++++++++++++++++++---------------------- src/mainwindow.h | 7 +++- src/networkaccessmanager.cpp | 1 + src/rekonqui.rc | 28 +++++++------- src/tabbar.cpp | 35 ++++++++++++----- 8 files changed, 113 insertions(+), 77 deletions(-) diff --git a/data/rekonq.desktop b/data/rekonq.desktop index a2aeca1b..2e9995dc 100644 --- a/data/rekonq.desktop +++ b/data/rekonq.desktop @@ -3,7 +3,7 @@ Name=rekonq GenericName=Webkit KDE Browser Icon=rekonq Type=Application -Exec=rekonq %i +Exec=rekonq %u DocPath=rekonq/index.html Categories=Qt;KDE;Network; Terminal=0 diff --git a/scripts/codingstyle.sh b/scripts/codingstyle.sh index f0fb984f..0ed5fb17 100755 --- a/scripts/codingstyle.sh +++ b/scripts/codingstyle.sh @@ -1,13 +1,28 @@ #!/bin/sh # -# apply kdelibs coding style to all c, cpp and header files in src directory +# apply rekonq coding style to all cpp and header files in src directory +# # requirements: installed astyle # -# The coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style +# rekonq use kdelibs coding style, except for brackets, so while kdelibs coding style +# is +# +# void foo() { +# ... +# } +# +# rekonq uses +# +# void foo() +# { +# ... +# } # -# In rekonq we use some little different rules.. +# I like this way, for me more readable. +# +# Kdelibs coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style + -{ PWD=$(pwd) cd $PWD @@ -24,4 +39,4 @@ astyle \ --convert-tabs \ --indent-preprocessor \ `find -type f -name '*.cpp'` `find -type f -name '*.h'` -} + diff --git a/src/main.cpp b/src/main.cpp index 9248aa14..b7cfbb3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) ki18n("rekonq"), version, ki18n(description), - KAboutData::License_GPL, + KAboutData::License_GPL_V3, ki18n("(C) 2008 Andrea Diamantini"), KLocalizedString(), "http://rekonq.sourceforge.net", diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d76b0d8d..5dd8663e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -76,7 +76,7 @@ MainWindow::MainWindow() // creating a centralWidget containing m_view and the hidden findbar QWidget *centralWidget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_view); // Find Bar @@ -102,6 +102,9 @@ MainWindow::MainWindow() connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); connect(m_view, SIGNAL(lastTabClosed()), m_view, SLOT(newTab())); + connect(m_view, SIGNAL(tabsChanged()), this, SLOT(slotUpdateActions())); + connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); + slotUpdateWindowTitle(); // then, setup our actions @@ -194,76 +197,76 @@ void MainWindow::setupActions() connect(a, SIGNAL(triggered(bool)), m_view, SLOT(slotWebStop())); // stop reload Action - m_stopReload = new KAction(KIcon("view-refresh"), i18n("reload"), this); - actionCollection()->addAction(QLatin1String("stop reload") , m_stopReload); + m_stopReloadAction = new KAction(KIcon("view-refresh"), i18n("reload"), this); + actionCollection()->addAction(QLatin1String("stop_reload") , m_stopReloadAction); + m_stopReloadAction->setShortcutConfigurable(false); // ============== Custom Actions a = new KAction(KIcon(), i18n("Open Location"), this); - actionCollection()->addAction(QLatin1String("open location"), a); + actionCollection()->addAction(QLatin1String("open_location"), a); connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotOpenLocation())); a = new KAction(i18n("Private &Browsing..."), this); a->setCheckable(true); - actionCollection()->addAction(i18n("private browsing"), a); + actionCollection()->addAction(i18n("private_browsing"), a); connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotPrivateBrowsing())); a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus)); - actionCollection()->addAction(QLatin1String("bigger font"), a); + actionCollection()->addAction(QLatin1String("bigger_font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextBigger())); a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0)); - actionCollection()->addAction(QLatin1String("normal font"), a); + actionCollection()->addAction(QLatin1String("normal_font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextNormal())); a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus)); - actionCollection()->addAction(QLatin1String("smaller font"), a); + actionCollection()->addAction(QLatin1String("smaller_font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextSmaller())); a = new KAction(i18n("Page S&ource"), this); - actionCollection()->addAction(QLatin1String("page source"), a); + actionCollection()->addAction(QLatin1String("page_source"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewPageSource())); a = new KAction(KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this); a->setCheckable(true); - actionCollection()->addAction(QLatin1String("web inspector"), a); + actionCollection()->addAction(QLatin1String("web_inspector"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotToggleInspector(bool))); // ================ history related actions - KAction *historyBack = new KAction(KIcon("go-previous"), i18n("Back"), this); + m_historyBackAction = new KAction(KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); - historyBack->setMenu(m_historyBackMenu); - connect(historyBack, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); -// FIXME < --------------------------------------------------------------------------------------------------------------------------------------| + m_historyBackAction->setMenu(m_historyBackMenu); + connect(m_historyBackAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - actionCollection()->addAction(QLatin1String("history back"), historyBack); + actionCollection()->addAction(QLatin1String("history_back"), m_historyBackAction); - KAction *historyForward = new KAction(KIcon("go-next"), i18n("Forward"), this); - connect(historyForward, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); - actionCollection()->addAction(QLatin1String("history forward"), historyForward); + m_historyForwardAction = new KAction(KIcon("go-next"), i18n("Forward"), this); + connect(m_historyForwardAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); + actionCollection()->addAction(QLatin1String("history_forward"), m_historyForwardAction); // =================== Tab Actions a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T)); - actionCollection()->addAction(QLatin1String("new tab"), a); + actionCollection()->addAction(QLatin1String("new_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_W)); - actionCollection()->addAction(QLatin1String("close tab"), a); + actionCollection()->addAction(QLatin1String("close_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(closeTab())); a = new KAction(i18n("Show Next Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); - actionCollection()->addAction(QLatin1String("show next tab"), a); + actionCollection()->addAction(QLatin1String("show_next_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); - actionCollection()->addAction(QLatin1String("show prev tab"), a); + actionCollection()->addAction(QLatin1String("show_prev_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab())); } @@ -272,14 +275,14 @@ void MainWindow::setupTabBar() { // Left corner button QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction(actionCollection()->action("new tab")); + addTabButton->setDefaultAction(actionCollection()->action("new_tab")); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(addTabButton, Qt::TopLeftCorner); // right corner button QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction(actionCollection()->action("close tab")); + closeTabButton->setDefaultAction(actionCollection()->action("close_tab")); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(closeTabButton, Qt::TopRightCorner); @@ -293,19 +296,9 @@ void MainWindow::setupHistoryMenu() connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle(i18n("&History")); menuBar()->insertMenu(actionCollection()->action("bookmarks"), historyMenu); - QList historyActions; - - historyActions.append(actionCollection()->action("history back")); - historyActions.append(actionCollection()->action("history forward")); - historyActions.append(m_view->recentlyClosedTabsAction()); - - historyMenu->setInitialActions(historyActions); } -// FIXME -// check ALL variables: including alwaysShowTabbar.. - void MainWindow::slotUpdateConf() { // ============== General ================== @@ -451,6 +444,13 @@ void MainWindow::slotUpdateStatusbar(const QString &string) } +void MainWindow::slotUpdateActions() +{ + m_historyBackAction->setEnabled(currentTab()->history()->canGoBack()); + m_historyForwardAction->setEnabled(currentTab()->history()->canGoForward()); +} + + void MainWindow::slotUpdateWindowTitle(const QString &title) { if (title.isEmpty()) @@ -628,7 +628,6 @@ void MainWindow::slotViewTextSmaller() } -// TODO improve this void MainWindow::slotViewFullScreen(bool makeFullScreen) { if (makeFullScreen == true) @@ -708,26 +707,25 @@ WebView *MainWindow::currentTab() const } -// FIXME: this actually doesn't work properly.. void MainWindow::slotLoadProgress(int progress) { QAction *stop = actionCollection()->action("stop"); QAction *reload = actionCollection()->action("view_redisplay"); if (progress < 100 && progress > 0) { - disconnect(m_stopReload, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); - m_stopReload->setIcon(KIcon("process-stop")); - m_stopReload->setToolTip(i18n("Stop loading the current page")); - m_stopReload->setText(i18n("Stop")); - connect(m_stopReload, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); + disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); + m_stopReloadAction->setIcon(KIcon("process-stop")); + m_stopReloadAction->setToolTip(i18n("Stop loading the current page")); + m_stopReloadAction->setText(i18n("Stop")); + connect(m_stopReloadAction, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); } else { - disconnect(m_stopReload, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); - m_stopReload->setIcon(KIcon("view-refresh")); - m_stopReload->setToolTip(i18n("Reload the current page")); - m_stopReload->setText(i18n("Reload")); - connect(m_stopReload, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); + disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); + m_stopReloadAction->setIcon(KIcon("view-refresh")); + m_stopReloadAction->setToolTip(i18n("Reload the current page")); + m_stopReloadAction->setText(i18n("Reload")); + connect(m_stopReloadAction, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 220fceca..c9bec75e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -74,6 +74,7 @@ private slots: void slotUpdateConf(); void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); + void slotUpdateActions(); void slotUpdateWindowTitle(const QString &title = QString()); void slotOpenLocation(); void slotAboutToShowBackMenu(); @@ -117,7 +118,11 @@ private: FindBar *m_findBar; KMenu *m_historyBackMenu; KMenu *m_windowMenu; - QAction *m_stopReload; + KAction *m_stopReloadAction; + KAction *m_stopAction; + KAction *m_reloadAction; + KAction *m_historyBackAction; + KAction *m_historyForwardAction; QString m_lastSearch; QString m_homePage; diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index c0b05e6a..3c15bcf5 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -37,6 +37,7 @@ // KDE Includes #include #include +#include // Qt Includes #include diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 332e04fe..babf2c62 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,6 +1,6 @@ - + @@ -8,17 +8,17 @@ &File - + - - + + - + @@ -39,14 +39,14 @@ &View - + - - - + + + - + @@ -59,7 +59,7 @@ - + @@ -69,9 +69,9 @@ Main Toolbar - - - + + + diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 43940f7d..cf3a1988 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -50,6 +50,14 @@ TabBar::TabBar(QWidget *parent) setAcceptDrops(true); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); + // we count to 9 because Ctrl+0 is already taken by Normal Font + for (int i = 1; i < 10; ++i) + { + QShortcut *tabShortCut = new QShortcut(QString("Ctrl+%1").arg(i), this); + connect(tabShortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); + m_tabShortcuts.append(tabShortCut); + } + QFont standardFont = KGlobalSettings::generalFont(); QString fontFamily = standardFont.family(); int dim = standardFont.pointSize(); @@ -64,16 +72,25 @@ TabBar::~TabBar() QSize TabBar::tabSizeHint(int index) const { - Q_UNUSED(index); QSize s = m_parent->sizeHint(); int w; - if (count() > 3) + + int n = count(); + + if(n > 6) { - w = s.width() / 4; + w = s.width() / 5; } else { - w = s.width() / 3; + if (n > 3) + { + w = s.width() / 4; + } + else + { + w = s.width() / 3; + } } int h = KTabBar::tabSizeHint(index).height(); @@ -81,22 +98,22 @@ QSize TabBar::tabSizeHint(int index) const return ts; } - + void TabBar::selectTabAction() { if (QShortcut *shortCut = qobject_cast(sender())) { int index = m_tabShortcuts.indexOf(shortCut); - if (index == 0) - index = 10; - setCurrentIndex(index); + if (index != 0) + { + setCurrentIndex(index); + } } } void TabBar::contextMenuRequested(const QPoint &position) { - // FIXME: use right actions KMenu menu; menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); -- cgit v1.2.1 From 98f53721514116b876d18bf0a2da89d2a53cc97d Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 00:05:45 +0100 Subject: Revert "pedantic" Too much things committed a time.. This reverts commit 651f97d0652e90ab1af4e80418f42468cc5932e2. --- data/rekonq.desktop | 2 +- scripts/codingstyle.sh | 25 +++--------- src/main.cpp | 2 +- src/mainwindow.cpp | 90 ++++++++++++++++++++++---------------------- src/mainwindow.h | 7 +--- src/networkaccessmanager.cpp | 1 - src/rekonqui.rc | 28 +++++++------- src/tabbar.cpp | 35 +++++------------ 8 files changed, 77 insertions(+), 113 deletions(-) diff --git a/data/rekonq.desktop b/data/rekonq.desktop index 2e9995dc..a2aeca1b 100644 --- a/data/rekonq.desktop +++ b/data/rekonq.desktop @@ -3,7 +3,7 @@ Name=rekonq GenericName=Webkit KDE Browser Icon=rekonq Type=Application -Exec=rekonq %u +Exec=rekonq %i DocPath=rekonq/index.html Categories=Qt;KDE;Network; Terminal=0 diff --git a/scripts/codingstyle.sh b/scripts/codingstyle.sh index 0ed5fb17..f0fb984f 100755 --- a/scripts/codingstyle.sh +++ b/scripts/codingstyle.sh @@ -1,28 +1,13 @@ #!/bin/sh # -# apply rekonq coding style to all cpp and header files in src directory -# +# apply kdelibs coding style to all c, cpp and header files in src directory # requirements: installed astyle # -# rekonq use kdelibs coding style, except for brackets, so while kdelibs coding style -# is -# -# void foo() { -# ... -# } -# -# rekonq uses -# -# void foo() -# { -# ... -# } +# The coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style # -# I like this way, for me more readable. -# -# Kdelibs coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style - +# In rekonq we use some little different rules.. +{ PWD=$(pwd) cd $PWD @@ -39,4 +24,4 @@ astyle \ --convert-tabs \ --indent-preprocessor \ `find -type f -name '*.cpp'` `find -type f -name '*.h'` - +} diff --git a/src/main.cpp b/src/main.cpp index b7cfbb3b..9248aa14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) ki18n("rekonq"), version, ki18n(description), - KAboutData::License_GPL_V3, + KAboutData::License_GPL, ki18n("(C) 2008 Andrea Diamantini"), KLocalizedString(), "http://rekonq.sourceforge.net", diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5dd8663e..d76b0d8d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -76,7 +76,7 @@ MainWindow::MainWindow() // creating a centralWidget containing m_view and the hidden findbar QWidget *centralWidget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); + layout->setMargin(0); layout->addWidget(m_view); // Find Bar @@ -102,9 +102,6 @@ MainWindow::MainWindow() connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); connect(m_view, SIGNAL(lastTabClosed()), m_view, SLOT(newTab())); - connect(m_view, SIGNAL(tabsChanged()), this, SLOT(slotUpdateActions())); - connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); - slotUpdateWindowTitle(); // then, setup our actions @@ -197,76 +194,76 @@ void MainWindow::setupActions() connect(a, SIGNAL(triggered(bool)), m_view, SLOT(slotWebStop())); // stop reload Action - m_stopReloadAction = new KAction(KIcon("view-refresh"), i18n("reload"), this); - actionCollection()->addAction(QLatin1String("stop_reload") , m_stopReloadAction); - m_stopReloadAction->setShortcutConfigurable(false); + m_stopReload = new KAction(KIcon("view-refresh"), i18n("reload"), this); + actionCollection()->addAction(QLatin1String("stop reload") , m_stopReload); // ============== Custom Actions a = new KAction(KIcon(), i18n("Open Location"), this); - actionCollection()->addAction(QLatin1String("open_location"), a); + actionCollection()->addAction(QLatin1String("open location"), a); connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotOpenLocation())); a = new KAction(i18n("Private &Browsing..."), this); a->setCheckable(true); - actionCollection()->addAction(i18n("private_browsing"), a); + actionCollection()->addAction(i18n("private browsing"), a); connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotPrivateBrowsing())); a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus)); - actionCollection()->addAction(QLatin1String("bigger_font"), a); + actionCollection()->addAction(QLatin1String("bigger font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextBigger())); a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0)); - actionCollection()->addAction(QLatin1String("normal_font"), a); + actionCollection()->addAction(QLatin1String("normal font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextNormal())); a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus)); - actionCollection()->addAction(QLatin1String("smaller_font"), a); + actionCollection()->addAction(QLatin1String("smaller font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextSmaller())); a = new KAction(i18n("Page S&ource"), this); - actionCollection()->addAction(QLatin1String("page_source"), a); + actionCollection()->addAction(QLatin1String("page source"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewPageSource())); a = new KAction(KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this); a->setCheckable(true); - actionCollection()->addAction(QLatin1String("web_inspector"), a); + actionCollection()->addAction(QLatin1String("web inspector"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotToggleInspector(bool))); // ================ history related actions - m_historyBackAction = new KAction(KIcon("go-previous"), i18n("Back"), this); + KAction *historyBack = new KAction(KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); - m_historyBackAction->setMenu(m_historyBackMenu); - connect(m_historyBackAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); + historyBack->setMenu(m_historyBackMenu); + connect(historyBack, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); +// FIXME < --------------------------------------------------------------------------------------------------------------------------------------| connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - actionCollection()->addAction(QLatin1String("history_back"), m_historyBackAction); + actionCollection()->addAction(QLatin1String("history back"), historyBack); - m_historyForwardAction = new KAction(KIcon("go-next"), i18n("Forward"), this); - connect(m_historyForwardAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); - actionCollection()->addAction(QLatin1String("history_forward"), m_historyForwardAction); + KAction *historyForward = new KAction(KIcon("go-next"), i18n("Forward"), this); + connect(historyForward, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); + actionCollection()->addAction(QLatin1String("history forward"), historyForward); // =================== Tab Actions a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T)); - actionCollection()->addAction(QLatin1String("new_tab"), a); + actionCollection()->addAction(QLatin1String("new tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_W)); - actionCollection()->addAction(QLatin1String("close_tab"), a); + actionCollection()->addAction(QLatin1String("close tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(closeTab())); a = new KAction(i18n("Show Next Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); - actionCollection()->addAction(QLatin1String("show_next_tab"), a); + actionCollection()->addAction(QLatin1String("show next tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); - actionCollection()->addAction(QLatin1String("show_prev_tab"), a); + actionCollection()->addAction(QLatin1String("show prev tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab())); } @@ -275,14 +272,14 @@ void MainWindow::setupTabBar() { // Left corner button QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction(actionCollection()->action("new_tab")); + addTabButton->setDefaultAction(actionCollection()->action("new tab")); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(addTabButton, Qt::TopLeftCorner); // right corner button QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction(actionCollection()->action("close_tab")); + closeTabButton->setDefaultAction(actionCollection()->action("close tab")); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(closeTabButton, Qt::TopRightCorner); @@ -296,9 +293,19 @@ void MainWindow::setupHistoryMenu() connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle(i18n("&History")); menuBar()->insertMenu(actionCollection()->action("bookmarks"), historyMenu); + QList historyActions; + + historyActions.append(actionCollection()->action("history back")); + historyActions.append(actionCollection()->action("history forward")); + historyActions.append(m_view->recentlyClosedTabsAction()); + + historyMenu->setInitialActions(historyActions); } +// FIXME +// check ALL variables: including alwaysShowTabbar.. + void MainWindow::slotUpdateConf() { // ============== General ================== @@ -444,13 +451,6 @@ void MainWindow::slotUpdateStatusbar(const QString &string) } -void MainWindow::slotUpdateActions() -{ - m_historyBackAction->setEnabled(currentTab()->history()->canGoBack()); - m_historyForwardAction->setEnabled(currentTab()->history()->canGoForward()); -} - - void MainWindow::slotUpdateWindowTitle(const QString &title) { if (title.isEmpty()) @@ -628,6 +628,7 @@ void MainWindow::slotViewTextSmaller() } +// TODO improve this void MainWindow::slotViewFullScreen(bool makeFullScreen) { if (makeFullScreen == true) @@ -707,25 +708,26 @@ WebView *MainWindow::currentTab() const } +// FIXME: this actually doesn't work properly.. void MainWindow::slotLoadProgress(int progress) { QAction *stop = actionCollection()->action("stop"); QAction *reload = actionCollection()->action("view_redisplay"); if (progress < 100 && progress > 0) { - disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); - m_stopReloadAction->setIcon(KIcon("process-stop")); - m_stopReloadAction->setToolTip(i18n("Stop loading the current page")); - m_stopReloadAction->setText(i18n("Stop")); - connect(m_stopReloadAction, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); + disconnect(m_stopReload, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); + m_stopReload->setIcon(KIcon("process-stop")); + m_stopReload->setToolTip(i18n("Stop loading the current page")); + m_stopReload->setText(i18n("Stop")); + connect(m_stopReload, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); } else { - disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); - m_stopReloadAction->setIcon(KIcon("view-refresh")); - m_stopReloadAction->setToolTip(i18n("Reload the current page")); - m_stopReloadAction->setText(i18n("Reload")); - connect(m_stopReloadAction, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); + disconnect(m_stopReload, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); + m_stopReload->setIcon(KIcon("view-refresh")); + m_stopReload->setToolTip(i18n("Reload the current page")); + m_stopReload->setText(i18n("Reload")); + connect(m_stopReload, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index c9bec75e..220fceca 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -74,7 +74,6 @@ private slots: void slotUpdateConf(); void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); - void slotUpdateActions(); void slotUpdateWindowTitle(const QString &title = QString()); void slotOpenLocation(); void slotAboutToShowBackMenu(); @@ -118,11 +117,7 @@ private: FindBar *m_findBar; KMenu *m_historyBackMenu; KMenu *m_windowMenu; - KAction *m_stopReloadAction; - KAction *m_stopAction; - KAction *m_reloadAction; - KAction *m_historyBackAction; - KAction *m_historyForwardAction; + QAction *m_stopReload; QString m_lastSearch; QString m_homePage; diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index 3c15bcf5..c0b05e6a 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -37,7 +37,6 @@ // KDE Includes #include #include -#include // Qt Includes #include diff --git a/src/rekonqui.rc b/src/rekonqui.rc index babf2c62..332e04fe 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,6 +1,6 @@ - + @@ -8,17 +8,17 @@ &File - + - - + + - + @@ -39,14 +39,14 @@ &View - + - - - + + + - + @@ -59,7 +59,7 @@ - + @@ -69,9 +69,9 @@ Main Toolbar - - - + + + diff --git a/src/tabbar.cpp b/src/tabbar.cpp index cf3a1988..43940f7d 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -50,14 +50,6 @@ TabBar::TabBar(QWidget *parent) setAcceptDrops(true); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); - // we count to 9 because Ctrl+0 is already taken by Normal Font - for (int i = 1; i < 10; ++i) - { - QShortcut *tabShortCut = new QShortcut(QString("Ctrl+%1").arg(i), this); - connect(tabShortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); - m_tabShortcuts.append(tabShortCut); - } - QFont standardFont = KGlobalSettings::generalFont(); QString fontFamily = standardFont.family(); int dim = standardFont.pointSize(); @@ -72,25 +64,16 @@ TabBar::~TabBar() QSize TabBar::tabSizeHint(int index) const { + Q_UNUSED(index); QSize s = m_parent->sizeHint(); int w; - - int n = count(); - - if(n > 6) + if (count() > 3) { - w = s.width() / 5; + w = s.width() / 4; } else { - if (n > 3) - { - w = s.width() / 4; - } - else - { - w = s.width() / 3; - } + w = s.width() / 3; } int h = KTabBar::tabSizeHint(index).height(); @@ -98,22 +81,22 @@ QSize TabBar::tabSizeHint(int index) const return ts; } - + void TabBar::selectTabAction() { if (QShortcut *shortCut = qobject_cast(sender())) { int index = m_tabShortcuts.indexOf(shortCut); - if (index != 0) - { - setCurrentIndex(index); - } + if (index == 0) + index = 10; + setCurrentIndex(index); } } void TabBar::contextMenuRequested(const QPoint &position) { + // FIXME: use right actions KMenu menu; menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); -- cgit v1.2.1 From 94d9bd4c079961c88a57cfc89a3771308823de2b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 00:10:49 +0100 Subject: merged some parts of pawel clone. In previous commit.. --- src/mainwindow.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5dd8663e..ed347bef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -19,7 +19,6 @@ * ============================================================ */ - // Self Includes #include "mainwindow.h" #include "mainwindow.moc" -- cgit v1.2.1 From 08deb6b161ef0cdda7ed8e49870b16f41d78eb4e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 00:13:01 +0100 Subject: Revert "Revert "pedantic"" Reapplied previous changes. Sorry for confusion. Time to bed.. This reverts commit 98f53721514116b876d18bf0a2da89d2a53cc97d. --- data/rekonq.desktop | 2 +- scripts/codingstyle.sh | 25 +++++++++--- src/main.cpp | 2 +- src/mainwindow.cpp | 90 ++++++++++++++++++++++---------------------- src/mainwindow.h | 7 +++- src/networkaccessmanager.cpp | 1 + src/rekonqui.rc | 28 +++++++------- src/tabbar.cpp | 35 ++++++++++++----- 8 files changed, 113 insertions(+), 77 deletions(-) diff --git a/data/rekonq.desktop b/data/rekonq.desktop index a2aeca1b..2e9995dc 100644 --- a/data/rekonq.desktop +++ b/data/rekonq.desktop @@ -3,7 +3,7 @@ Name=rekonq GenericName=Webkit KDE Browser Icon=rekonq Type=Application -Exec=rekonq %i +Exec=rekonq %u DocPath=rekonq/index.html Categories=Qt;KDE;Network; Terminal=0 diff --git a/scripts/codingstyle.sh b/scripts/codingstyle.sh index f0fb984f..0ed5fb17 100755 --- a/scripts/codingstyle.sh +++ b/scripts/codingstyle.sh @@ -1,13 +1,28 @@ #!/bin/sh # -# apply kdelibs coding style to all c, cpp and header files in src directory +# apply rekonq coding style to all cpp and header files in src directory +# # requirements: installed astyle # -# The coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style +# rekonq use kdelibs coding style, except for brackets, so while kdelibs coding style +# is +# +# void foo() { +# ... +# } +# +# rekonq uses +# +# void foo() +# { +# ... +# } # -# In rekonq we use some little different rules.. +# I like this way, for me more readable. +# +# Kdelibs coding style is defined in http://techbase.kde.org/Policies/Kdelibs_Coding_Style + -{ PWD=$(pwd) cd $PWD @@ -24,4 +39,4 @@ astyle \ --convert-tabs \ --indent-preprocessor \ `find -type f -name '*.cpp'` `find -type f -name '*.h'` -} + diff --git a/src/main.cpp b/src/main.cpp index 9248aa14..b7cfbb3b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) ki18n("rekonq"), version, ki18n(description), - KAboutData::License_GPL, + KAboutData::License_GPL_V3, ki18n("(C) 2008 Andrea Diamantini"), KLocalizedString(), "http://rekonq.sourceforge.net", diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3f252ca2..ed347bef 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -75,7 +75,7 @@ MainWindow::MainWindow() // creating a centralWidget containing m_view and the hidden findbar QWidget *centralWidget = new QWidget; QVBoxLayout *layout = new QVBoxLayout; - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_view); // Find Bar @@ -101,6 +101,9 @@ MainWindow::MainWindow() connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); connect(m_view, SIGNAL(lastTabClosed()), m_view, SLOT(newTab())); + connect(m_view, SIGNAL(tabsChanged()), this, SLOT(slotUpdateActions())); + connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); + slotUpdateWindowTitle(); // then, setup our actions @@ -193,76 +196,76 @@ void MainWindow::setupActions() connect(a, SIGNAL(triggered(bool)), m_view, SLOT(slotWebStop())); // stop reload Action - m_stopReload = new KAction(KIcon("view-refresh"), i18n("reload"), this); - actionCollection()->addAction(QLatin1String("stop reload") , m_stopReload); + m_stopReloadAction = new KAction(KIcon("view-refresh"), i18n("reload"), this); + actionCollection()->addAction(QLatin1String("stop_reload") , m_stopReloadAction); + m_stopReloadAction->setShortcutConfigurable(false); // ============== Custom Actions a = new KAction(KIcon(), i18n("Open Location"), this); - actionCollection()->addAction(QLatin1String("open location"), a); + actionCollection()->addAction(QLatin1String("open_location"), a); connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotOpenLocation())); a = new KAction(i18n("Private &Browsing..."), this); a->setCheckable(true); - actionCollection()->addAction(i18n("private browsing"), a); + actionCollection()->addAction(i18n("private_browsing"), a); connect(a, SIGNAL(triggered(bool)) , this, SLOT(slotPrivateBrowsing())); a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Plus)); - actionCollection()->addAction(QLatin1String("bigger font"), a); + actionCollection()->addAction(QLatin1String("bigger_font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextBigger())); a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0)); - actionCollection()->addAction(QLatin1String("normal font"), a); + actionCollection()->addAction(QLatin1String("normal_font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextNormal())); a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this); a->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Minus)); - actionCollection()->addAction(QLatin1String("smaller font"), a); + actionCollection()->addAction(QLatin1String("smaller_font"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewTextSmaller())); a = new KAction(i18n("Page S&ource"), this); - actionCollection()->addAction(QLatin1String("page source"), a); + actionCollection()->addAction(QLatin1String("page_source"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotViewPageSource())); a = new KAction(KIcon("tools-report-bug"), i18n("Enable Web &Inspector"), this); a->setCheckable(true); - actionCollection()->addAction(QLatin1String("web inspector"), a); + actionCollection()->addAction(QLatin1String("web_inspector"), a); connect(a, SIGNAL(triggered(bool)), this, SLOT(slotToggleInspector(bool))); // ================ history related actions - KAction *historyBack = new KAction(KIcon("go-previous"), i18n("Back"), this); + m_historyBackAction = new KAction(KIcon("go-previous"), i18n("Back"), this); m_historyBackMenu = new KMenu(this); - historyBack->setMenu(m_historyBackMenu); - connect(historyBack, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); -// FIXME < --------------------------------------------------------------------------------------------------------------------------------------| + m_historyBackAction->setMenu(m_historyBackMenu); + connect(m_historyBackAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenPrevious())); connect(m_historyBackMenu, SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowBackMenu())); connect(m_historyBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotOpenActionUrl(QAction *))); - actionCollection()->addAction(QLatin1String("history back"), historyBack); + actionCollection()->addAction(QLatin1String("history_back"), m_historyBackAction); - KAction *historyForward = new KAction(KIcon("go-next"), i18n("Forward"), this); - connect(historyForward, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); - actionCollection()->addAction(QLatin1String("history forward"), historyForward); + m_historyForwardAction = new KAction(KIcon("go-next"), i18n("Forward"), this); + connect(m_historyForwardAction, SIGNAL(triggered(bool)), this, SLOT(slotOpenNext())); + actionCollection()->addAction(QLatin1String("history_forward"), m_historyForwardAction); // =================== Tab Actions a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T)); - actionCollection()->addAction(QLatin1String("new tab"), a); + actionCollection()->addAction(QLatin1String("new_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_W)); - actionCollection()->addAction(QLatin1String("close tab"), a); + actionCollection()->addAction(QLatin1String("close_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(closeTab())); a = new KAction(i18n("Show Next Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabPrev() : KStandardShortcut::tabNext()); - actionCollection()->addAction(QLatin1String("show next tab"), a); + actionCollection()->addAction(QLatin1String("show_next_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(nextTab())); a = new KAction(i18n("Show Previous Tab"), this); a->setShortcuts(QApplication::isRightToLeft() ? KStandardShortcut::tabNext() : KStandardShortcut::tabPrev()); - actionCollection()->addAction(QLatin1String("show prev tab"), a); + actionCollection()->addAction(QLatin1String("show_prev_tab"), a); connect(a, SIGNAL(triggered(bool)), m_view, SLOT(previousTab())); } @@ -271,14 +274,14 @@ void MainWindow::setupTabBar() { // Left corner button QToolButton *addTabButton = new QToolButton(this); - addTabButton->setDefaultAction(actionCollection()->action("new tab")); + addTabButton->setDefaultAction(actionCollection()->action("new_tab")); addTabButton->setAutoRaise(true); addTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(addTabButton, Qt::TopLeftCorner); // right corner button QToolButton *closeTabButton = new QToolButton(this); - closeTabButton->setDefaultAction(actionCollection()->action("close tab")); + closeTabButton->setDefaultAction(actionCollection()->action("close_tab")); closeTabButton->setAutoRaise(true); closeTabButton->setToolButtonStyle(Qt::ToolButtonIconOnly); m_view->setCornerWidget(closeTabButton, Qt::TopRightCorner); @@ -292,19 +295,9 @@ void MainWindow::setupHistoryMenu() connect(historyMenu, SIGNAL(hovered(const QString&)), this, SLOT(slotUpdateStatusbar(const QString&))); historyMenu->setTitle(i18n("&History")); menuBar()->insertMenu(actionCollection()->action("bookmarks"), historyMenu); - QList historyActions; - - historyActions.append(actionCollection()->action("history back")); - historyActions.append(actionCollection()->action("history forward")); - historyActions.append(m_view->recentlyClosedTabsAction()); - - historyMenu->setInitialActions(historyActions); } -// FIXME -// check ALL variables: including alwaysShowTabbar.. - void MainWindow::slotUpdateConf() { // ============== General ================== @@ -450,6 +443,13 @@ void MainWindow::slotUpdateStatusbar(const QString &string) } +void MainWindow::slotUpdateActions() +{ + m_historyBackAction->setEnabled(currentTab()->history()->canGoBack()); + m_historyForwardAction->setEnabled(currentTab()->history()->canGoForward()); +} + + void MainWindow::slotUpdateWindowTitle(const QString &title) { if (title.isEmpty()) @@ -627,7 +627,6 @@ void MainWindow::slotViewTextSmaller() } -// TODO improve this void MainWindow::slotViewFullScreen(bool makeFullScreen) { if (makeFullScreen == true) @@ -707,26 +706,25 @@ WebView *MainWindow::currentTab() const } -// FIXME: this actually doesn't work properly.. void MainWindow::slotLoadProgress(int progress) { QAction *stop = actionCollection()->action("stop"); QAction *reload = actionCollection()->action("view_redisplay"); if (progress < 100 && progress > 0) { - disconnect(m_stopReload, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); - m_stopReload->setIcon(KIcon("process-stop")); - m_stopReload->setToolTip(i18n("Stop loading the current page")); - m_stopReload->setText(i18n("Stop")); - connect(m_stopReload, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); + disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); + m_stopReloadAction->setIcon(KIcon("process-stop")); + m_stopReloadAction->setToolTip(i18n("Stop loading the current page")); + m_stopReloadAction->setText(i18n("Stop")); + connect(m_stopReloadAction, SIGNAL(triggered(bool)), stop, SIGNAL(triggered(bool))); } else { - disconnect(m_stopReload, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); - m_stopReload->setIcon(KIcon("view-refresh")); - m_stopReload->setToolTip(i18n("Reload the current page")); - m_stopReload->setText(i18n("Reload")); - connect(m_stopReload, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); + disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), stop , SIGNAL(triggered(bool))); + m_stopReloadAction->setIcon(KIcon("view-refresh")); + m_stopReloadAction->setToolTip(i18n("Reload the current page")); + m_stopReloadAction->setText(i18n("Reload")); + connect(m_stopReloadAction, SIGNAL(triggered(bool)), reload, SIGNAL(triggered(bool))); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 220fceca..c9bec75e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -74,6 +74,7 @@ private slots: void slotUpdateConf(); void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); + void slotUpdateActions(); void slotUpdateWindowTitle(const QString &title = QString()); void slotOpenLocation(); void slotAboutToShowBackMenu(); @@ -117,7 +118,11 @@ private: FindBar *m_findBar; KMenu *m_historyBackMenu; KMenu *m_windowMenu; - QAction *m_stopReload; + KAction *m_stopReloadAction; + KAction *m_stopAction; + KAction *m_reloadAction; + KAction *m_historyBackAction; + KAction *m_historyForwardAction; QString m_lastSearch; QString m_homePage; diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp index c0b05e6a..3c15bcf5 100644 --- a/src/networkaccessmanager.cpp +++ b/src/networkaccessmanager.cpp @@ -37,6 +37,7 @@ // KDE Includes #include #include +#include // Qt Includes #include diff --git a/src/rekonqui.rc b/src/rekonqui.rc index 332e04fe..babf2c62 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,6 +1,6 @@ - + @@ -8,17 +8,17 @@ &File - + - - + + - + @@ -39,14 +39,14 @@ &View - + - - - + + + - + @@ -59,7 +59,7 @@ - + @@ -69,9 +69,9 @@ Main Toolbar - - - + + + diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 43940f7d..cf3a1988 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -50,6 +50,14 @@ TabBar::TabBar(QWidget *parent) setAcceptDrops(true); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); + // we count to 9 because Ctrl+0 is already taken by Normal Font + for (int i = 1; i < 10; ++i) + { + QShortcut *tabShortCut = new QShortcut(QString("Ctrl+%1").arg(i), this); + connect(tabShortCut, SIGNAL(activated()), this, SLOT(selectTabAction())); + m_tabShortcuts.append(tabShortCut); + } + QFont standardFont = KGlobalSettings::generalFont(); QString fontFamily = standardFont.family(); int dim = standardFont.pointSize(); @@ -64,16 +72,25 @@ TabBar::~TabBar() QSize TabBar::tabSizeHint(int index) const { - Q_UNUSED(index); QSize s = m_parent->sizeHint(); int w; - if (count() > 3) + + int n = count(); + + if(n > 6) { - w = s.width() / 4; + w = s.width() / 5; } else { - w = s.width() / 3; + if (n > 3) + { + w = s.width() / 4; + } + else + { + w = s.width() / 3; + } } int h = KTabBar::tabSizeHint(index).height(); @@ -81,22 +98,22 @@ QSize TabBar::tabSizeHint(int index) const return ts; } - + void TabBar::selectTabAction() { if (QShortcut *shortCut = qobject_cast(sender())) { int index = m_tabShortcuts.indexOf(shortCut); - if (index == 0) - index = 10; - setCurrentIndex(index); + if (index != 0) + { + setCurrentIndex(index); + } } } void TabBar::contextMenuRequested(const QPoint &position) { - // FIXME: use right actions KMenu menu; menu.addAction(i18n("New &Tab"), this, SIGNAL(newTab()), QKeySequence::AddTab); int index = tabAt(position); -- cgit v1.2.1 From 9af2a171f5c49a435ca19a996583f6130ec1dee8 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 00:21:38 +0100 Subject: imported Avaddon clone (just some bits) --- po/CMakeLists.txt | 34 +++ po/rekonq.pot | 277 +++++++++---------- po/rekonq_ru.po | 750 ++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/Messages.sh | 42 ++- 4 files changed, 966 insertions(+), 137 deletions(-) create mode 100644 po/CMakeLists.txt create mode 100644 po/rekonq_ru.po diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt new file mode 100644 index 00000000..261e9e4c --- /dev/null +++ b/po/CMakeLists.txt @@ -0,0 +1,34 @@ +FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) + +IF(NOT GETTEXT_MSGFMT_EXECUTABLE) + MESSAGE( +"------ + NOTE: msgfmt not found. Translations will *not* be installed +------") +ELSE(NOT GETTEXT_MSGFMT_EXECUTABLE) + + SET(catalogname rekonq) + + ADD_CUSTOM_TARGET(translations ALL) + + FILE(GLOB PO_FILES ${catalogname}*.po) + + FOREACH(_poFile ${PO_FILES}) + GET_FILENAME_COMPONENT(_poFileName ${_poFile} NAME) + STRING(REGEX REPLACE "^${catalogname}_?" "" _langCode ${_poFileName} ) + STRING(REGEX REPLACE "\\.po$" "" _langCode ${_langCode} ) + + IF( _langCode ) + GET_FILENAME_COMPONENT(_lang ${_poFile} NAME_WE) + SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) + + ADD_CUSTOM_COMMAND(TARGET translations + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} --check -o ${_gmoFile} ${_poFile} + DEPENDS ${_poFile}) + INSTALL(FILES ${_gmoFile} DESTINATION ${LOCALE_INSTALL_DIR}/${_langCode}/LC_MESSAGES/ RENAME ${catalogname}.mo) + ENDIF( _langCode ) + + ENDFOREACH(_poFile ${PO_FILES}) + +ENDIF(NOT GETTEXT_MSGFMT_EXECUTABLE) + diff --git a/po/rekonq.pot b/po/rekonq.pot index 9ce50dd8..74d1ce5c 100644 --- a/po/rekonq.pot +++ b/po/rekonq.pot @@ -7,9 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" -"group_id=252277&atid=1126949\n" -"POT-Creation-Date: 2009-03-25 01:44+0100\n" +"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?\n" +"POT-Creation-Date: 2009-03-28 23:04+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,85 +16,85 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: cookiejar.cpp:469 cookiejar.cpp:638 +#: cookiejar.cpp:472 cookiejar.cpp:651 msgid "Website" msgstr "" -#: cookiejar.cpp:471 +#: cookiejar.cpp:474 msgid "Name" msgstr "" -#: cookiejar.cpp:473 +#: cookiejar.cpp:476 msgid "Path" msgstr "" -#: cookiejar.cpp:475 +#: cookiejar.cpp:478 msgid "Secure" msgstr "" -#: cookiejar.cpp:477 +#: cookiejar.cpp:480 msgid "Expires" msgstr "" -#: cookiejar.cpp:479 +#: cookiejar.cpp:482 msgid "Contents" msgstr "" -#: cookiejar.cpp:640 +#: cookiejar.cpp:653 msgid "Status" msgstr "" #. i18n: file: cookiesexceptions.ui:77 #. i18n: ectx: property (text), widget (QPushButton, allowButton) -#: cookiejar.cpp:661 rc.cpp:27 +#: cookiejar.cpp:678 rc.cpp:18 msgid "Allow" msgstr "" #. i18n: file: cookiesexceptions.ui:57 #. i18n: ectx: property (text), widget (QPushButton, blockButton) -#: cookiejar.cpp:670 rc.cpp:21 +#: cookiejar.cpp:689 rc.cpp:12 msgid "Block" msgstr "" #. i18n: file: cookiesexceptions.ui:67 #. i18n: ectx: property (text), widget (QPushButton, allowForSessionButton) -#: cookiejar.cpp:679 rc.cpp:24 +#: cookiejar.cpp:700 rc.cpp:15 msgid "Allow For Session" msgstr "" -#: history.cpp:416 +#: history.cpp:422 msgid "Title" msgstr "" -#: history.cpp:417 +#: history.cpp:423 msgid "Address" msgstr "" -#: history.cpp:657 +#: history.cpp:680 msgid "Show All History" msgstr "" -#: history.cpp:661 +#: history.cpp:684 msgid "Clear History" msgstr "" -#: history.cpp:739 +#: history.cpp:765 msgid "Open" msgstr "" -#: history.cpp:741 +#: history.cpp:767 msgid "Copy" msgstr "" -#: history.cpp:743 +#: history.cpp:769 msgid "Delete" msgstr "" -#: history.cpp:1111 +#: history.cpp:1152 msgid "Earlier Today" msgstr "" -#: history.cpp:1115 +#: history.cpp:1157 msgid " items" msgstr "" @@ -119,70 +118,70 @@ msgstr "" msgid "Location to open" msgstr "" -#: mainview.cpp:76 +#: mainview.cpp:77 msgid "Recently Closed Tabs" msgstr "" -#: mainview.cpp:368 mainview.cpp:392 +#: mainview.cpp:370 mainview.cpp:395 msgid "(Untitled)" msgstr "" -#: mainview.cpp:488 +#: mainview.cpp:491 msgid "" "You have modified this page and when closing it you would lose the " "modification.\n" "Do you really want to close this page?\n" msgstr "" -#: mainview.cpp:490 +#: mainview.cpp:493 msgid "Do you really want to close this page?" msgstr "" -#: mainwindow.cpp:114 +#: mainwindow.cpp:113 msgid "B&ookmarks" msgstr "" -#: mainwindow.cpp:191 +#: mainwindow.cpp:190 msgid "&Stop" msgstr "" -#: mainwindow.cpp:197 +#: mainwindow.cpp:196 msgid "reload" msgstr "" -#: mainwindow.cpp:201 +#: mainwindow.cpp:200 msgid "Open Location" msgstr "" -#: mainwindow.cpp:205 +#: mainwindow.cpp:204 msgid "Private &Browsing..." msgstr "" -#: mainwindow.cpp:207 +#: mainwindow.cpp:206 msgid "private browsing" msgstr "" -#: mainwindow.cpp:210 +#: mainwindow.cpp:209 msgid "&Enlarge Font" msgstr "" -#: mainwindow.cpp:215 +#: mainwindow.cpp:214 msgid "&Normal Font" msgstr "" -#: mainwindow.cpp:220 +#: mainwindow.cpp:219 msgid "&Shrink Font" msgstr "" -#: mainwindow.cpp:225 +#: mainwindow.cpp:224 msgid "Page S&ource" msgstr "" -#: mainwindow.cpp:229 +#: mainwindow.cpp:228 msgid "Enable Web &Inspector" msgstr "" -#: mainwindow.cpp:235 +#: mainwindow.cpp:234 msgid "Back" msgstr "" @@ -240,54 +239,54 @@ msgstr "" msgid " not found." msgstr "" -#: mainwindow.cpp:644 +#: mainwindow.cpp:654 msgid "Page Source of " msgstr "" -#: mainwindow.cpp:663 +#: mainwindow.cpp:673 msgid "" "The web inspector will only work correctly for pages that were loaded after " "enabling.\n" "Do you want to reload all pages?" msgstr "" -#: mainwindow.cpp:665 +#: mainwindow.cpp:675 msgid "Web Inspector" msgstr "" -#: mainwindow.cpp:709 +#: mainwindow.cpp:719 msgid "Stop loading the current page" msgstr "" -#: mainwindow.cpp:710 +#: mainwindow.cpp:720 msgid "Stop" msgstr "" -#: mainwindow.cpp:717 +#: mainwindow.cpp:727 msgid "Reload the current page" msgstr "" -#: mainwindow.cpp:718 +#: mainwindow.cpp:728 msgid "Reload" msgstr "" -#: networkaccessmanager.cpp:103 +#: networkaccessmanager.cpp:116 msgid "Enter username and password for " msgstr "" -#: networkaccessmanager.cpp:104 +#: networkaccessmanager.cpp:117 msgid " at " msgstr "" -#: networkaccessmanager.cpp:128 +#: networkaccessmanager.cpp:141 msgid "Connect to proxy " msgstr "" -#: networkaccessmanager.cpp:128 +#: networkaccessmanager.cpp:141 msgid " using:" msgstr "" -#: networkaccessmanager.cpp:148 +#: networkaccessmanager.cpp:161 msgid "" "SSL Errors:\n" "\n" @@ -299,29 +298,33 @@ msgstr "" #. i18n: file: settings_general.ui:14 #. i18n: ectx: property (windowTitle), widget (QWidget, general) -#: settings.cpp:78 rc.cpp:111 +#: settings.cpp:80 rc.cpp:111 msgid "General" msgstr "" #. i18n: file: settings_fonts.ui:20 #. i18n: ectx: property (title), widget (QGroupBox, groupBox) -#: settings.cpp:84 rc.cpp:96 +#: settings.cpp:86 rc.cpp:96 msgid "Fonts" msgstr "" #. i18n: file: settings_privacy.ui:14 #. i18n: ectx: property (windowTitle), widget (QWidget, privacy) -#: settings.cpp:90 rc.cpp:141 +#: settings.cpp:92 rc.cpp:135 msgid "Privacy" msgstr "" #. i18n: file: settings_proxy.ui:13 #. i18n: ectx: property (windowTitle), widget (QWidget, proxy) -#: settings.cpp:96 rc.cpp:201 +#: settings.cpp:98 rc.cpp:195 msgid "Proxy" msgstr "" -#: settings.cpp:109 +#: settings.cpp:104 +msgid "Interface" +msgstr "" + +#: settings.cpp:117 msgid "rekonfig.." msgstr "" @@ -341,75 +344,75 @@ msgstr "" msgid "Reload All Tabs" msgstr "" -#: webview.cpp:162 +#: webview.cpp:163 msgid "Error loading page: " msgstr "" -#: webview.cpp:220 +#: webview.cpp:221 msgid "Open in New Tab" msgstr "" -#. i18n: file: cookies.ui:14 -#. i18n: ectx: property (windowTitle), widget (QDialog, CookiesDialog) -#. i18n: file: settings_privacy.ui:73 -#. i18n: ectx: property (title), widget (QGroupBox, cookiesGroupBox) -#: rc.cpp:3 rc.cpp:168 -msgid "Cookies" -msgstr "" - -#. i18n: file: cookies.ui:41 -#. i18n: ectx: property (text), widget (QPushButton, removeButton) -#. i18n: file: cookiesexceptions.ui:114 -#. i18n: ectx: property (text), widget (QPushButton, removeButton) -#. i18n: file: history.ui:40 -#. i18n: ectx: property (text), widget (QPushButton, removeButton) -#: rc.cpp:6 rc.cpp:33 rc.cpp:42 -msgid "&Remove" -msgstr "" - -#. i18n: file: cookies.ui:48 -#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) -#: rc.cpp:9 -msgid "Remove &All Cookies" -msgstr "" - #. i18n: file: cookiesexceptions.ui:13 #. i18n: ectx: property (windowTitle), widget (QDialog, CookiesExceptionsDialog) -#: rc.cpp:12 +#: rc.cpp:3 msgid "Cookie Exceptions" msgstr "" #. i18n: file: cookiesexceptions.ui:19 #. i18n: ectx: property (title), widget (QGroupBox, newExceptionGroupBox) -#: rc.cpp:15 +#: rc.cpp:6 msgid "New Exception" msgstr "" #. i18n: file: cookiesexceptions.ui:27 #. i18n: ectx: property (text), widget (QLabel, label) -#: rc.cpp:18 +#: rc.cpp:9 msgid "Domain:" msgstr "" #. i18n: file: cookiesexceptions.ui:89 #. i18n: ectx: property (title), widget (QGroupBox, ExceptionsGroupBox) -#: rc.cpp:30 +#: rc.cpp:21 msgid "Exceptions" msgstr "" +#. i18n: file: cookiesexceptions.ui:114 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#. i18n: file: cookies.ui:41 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#. i18n: file: history.ui:40 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#: rc.cpp:24 rc.cpp:33 rc.cpp:42 +msgid "&Remove" +msgstr "" + #. i18n: file: cookiesexceptions.ui:121 #. i18n: ectx: property (text), widget (QPushButton, removeAllButton) #. i18n: file: history.ui:47 #. i18n: ectx: property (text), widget (QPushButton, removeAllButton) -#: rc.cpp:36 rc.cpp:45 +#: rc.cpp:27 rc.cpp:45 msgid "Remove &All" msgstr "" +#. i18n: file: cookies.ui:14 +#. i18n: ectx: property (windowTitle), widget (QDialog, CookiesDialog) +#. i18n: file: settings_privacy.ui:73 +#. i18n: ectx: property (title), widget (QGroupBox, cookiesGroupBox) +#: rc.cpp:30 rc.cpp:162 +msgid "Cookies" +msgstr "" + +#. i18n: file: cookies.ui:48 +#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) +#: rc.cpp:36 +msgid "Remove &All Cookies" +msgstr "" + #. i18n: file: history.ui:13 #. i18n: ectx: property (windowTitle), widget (QDialog, HistoryDialog) #. i18n: file: settings_privacy.ui:20 #. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) -#: rc.cpp:39 rc.cpp:144 +#: rc.cpp:39 rc.cpp:138 msgid "History" msgstr "" @@ -445,7 +448,7 @@ msgstr "" #. i18n: ectx: property (text), widget (QLabel, passwordLabel) #. i18n: file: settings_proxy.ui:115 #. i18n: ectx: property (text), widget (QLabel, label_13) -#: rc.cpp:60 rc.cpp:75 rc.cpp:228 +#: rc.cpp:60 rc.cpp:75 rc.cpp:222 msgid "Password:" msgstr "" @@ -499,9 +502,7 @@ msgstr "" #. i18n: file: settings_fonts.ui:14 #. i18n: ectx: property (windowTitle), widget (QWidget, fonts) -#. i18n: file: settings_general.ui:86 -#. i18n: ectx: property (title), widget (QGroupBox, groupBox_3) -#: rc.cpp:93 rc.cpp:126 +#: rc.cpp:93 msgid "Appearance" msgstr "" @@ -553,186 +554,194 @@ msgstr "" msgid "Save downloads to:" msgstr "" -#. i18n: file: settings_general.ui:92 -#. i18n: ectx: property (text), widget (QCheckBox, kcfg_alwaysShowTabBar) -#: rc.cpp:129 -msgid "Always show TabBar" -msgstr "" - -#. i18n: file: settings_general.ui:102 +#. i18n: file: settings_general.ui:86 #. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) -#: rc.cpp:132 +#: rc.cpp:126 msgid "Web Content" msgstr "" -#. i18n: file: settings_general.ui:108 +#. i18n: file: settings_general.ui:92 #. i18n: ectx: property (text), widget (QCheckBox, kcfg_enablePlugins) -#: rc.cpp:135 +#: rc.cpp:129 msgid "Enable Plugins" msgstr "" -#. i18n: file: settings_general.ui:118 +#. i18n: file: settings_general.ui:102 #. i18n: ectx: property (text), widget (QCheckBox, kcfg_enableJavascript) -#: rc.cpp:138 +#: rc.cpp:132 msgid "Enable Javascript" msgstr "" #. i18n: file: settings_privacy.ui:26 #. i18n: ectx: property (text), widget (QLabel, label_4) -#: rc.cpp:147 +#: rc.cpp:141 msgid "Remove history items:" msgstr "" #. i18n: file: settings_privacy.ui:37 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) -#: rc.cpp:150 +#: rc.cpp:144 msgid "After one day" msgstr "" #. i18n: file: settings_privacy.ui:42 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) -#: rc.cpp:153 +#: rc.cpp:147 msgid "After one week" msgstr "" #. i18n: file: settings_privacy.ui:47 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) -#: rc.cpp:156 +#: rc.cpp:150 msgid "After two weeks" msgstr "" #. i18n: file: settings_privacy.ui:52 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) -#: rc.cpp:159 +#: rc.cpp:153 msgid "After one month" msgstr "" #. i18n: file: settings_privacy.ui:57 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) -#: rc.cpp:162 +#: rc.cpp:156 msgid "After one year" msgstr "" #. i18n: file: settings_privacy.ui:62 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) -#: rc.cpp:165 +#: rc.cpp:159 msgid "Manually" msgstr "" #. i18n: file: settings_privacy.ui:79 #. i18n: ectx: property (text), widget (QLabel, label_2) -#: rc.cpp:171 +#: rc.cpp:165 msgid "Accept Cookies:" msgstr "" #. i18n: file: settings_privacy.ui:90 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) -#: rc.cpp:174 +#: rc.cpp:168 msgid "Always" msgstr "" #. i18n: file: settings_privacy.ui:95 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) -#: rc.cpp:177 +#: rc.cpp:171 msgid "Never" msgstr "" #. i18n: file: settings_privacy.ui:100 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) -#: rc.cpp:180 +#: rc.cpp:174 msgid "Only from sites you navigate to" msgstr "" #. i18n: file: settings_privacy.ui:108 #. i18n: ectx: property (text), widget (QPushButton, exceptionsButton) -#: rc.cpp:183 +#: rc.cpp:177 msgid "Exceptions..." msgstr "" #. i18n: file: settings_privacy.ui:115 #. i18n: ectx: property (text), widget (QLabel, label) -#: rc.cpp:186 +#: rc.cpp:180 msgid "Keep until:" msgstr "" #. i18n: file: settings_privacy.ui:126 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) -#: rc.cpp:189 +#: rc.cpp:183 msgid "They expire" msgstr "" #. i18n: file: settings_privacy.ui:131 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) -#: rc.cpp:192 +#: rc.cpp:186 msgid "I exit the application" msgstr "" #. i18n: file: settings_privacy.ui:136 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) -#: rc.cpp:195 +#: rc.cpp:189 msgid "At most 90 days" msgstr "" #. i18n: file: settings_privacy.ui:144 #. i18n: ectx: property (text), widget (QPushButton, cookiesButton) -#: rc.cpp:198 +#: rc.cpp:192 msgid "Cookies..." msgstr "" #. i18n: file: settings_proxy.ui:19 #. i18n: ectx: property (text), widget (QCheckBox, kcfg_isProxyEnabled) -#: rc.cpp:204 +#: rc.cpp:198 msgid "enable proxy" msgstr "" #. i18n: file: settings_proxy.ui:26 #. i18n: ectx: property (title), widget (QGroupBox, groupBox) -#: rc.cpp:207 +#: rc.cpp:201 msgid "Proxy Settings" msgstr "" #. i18n: file: settings_proxy.ui:32 #. i18n: ectx: property (text), widget (QLabel, label_9) -#: rc.cpp:210 +#: rc.cpp:204 msgid "Type:" msgstr "" #. i18n: file: settings_proxy.ui:43 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_proxyType) -#: rc.cpp:213 +#: rc.cpp:207 msgid "Socks5" msgstr "" #. i18n: file: settings_proxy.ui:48 #. i18n: ectx: property (text), item, widget (QComboBox, kcfg_proxyType) -#: rc.cpp:216 +#: rc.cpp:210 msgid "Http" msgstr "" #. i18n: file: settings_proxy.ui:56 #. i18n: ectx: property (text), widget (QLabel, label_10) -#: rc.cpp:219 +#: rc.cpp:213 msgid "Host:" msgstr "" #. i18n: file: settings_proxy.ui:69 #. i18n: ectx: property (text), widget (QLabel, label_11) -#: rc.cpp:222 +#: rc.cpp:216 msgid "Port:" msgstr "" #. i18n: file: settings_proxy.ui:102 #. i18n: ectx: property (text), widget (QLabel, label_12) -#: rc.cpp:225 +#: rc.cpp:219 msgid "User Name:" msgstr "" -#: rc.cpp:229 -msgctxt "NAME OF TRANSLATORS" -msgid "Andrea Diamantini" +#. i18n: file: settings_ui.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, ui) +#: rc.cpp:225 +msgid "Ui" msgstr "" -#: rc.cpp:230 -msgctxt "EMAIL OF TRANSLATORS" -msgid "adjam7@gmail.com" +#. i18n: file: settings_ui.ui:20 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_enableLocationbarProgressIndicator) +#: rc.cpp:228 +msgid "Enable location bar progress indication" +msgstr "" + +#. i18n: file: settings_ui.ui:34 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_closeWithLastTab) +#: rc.cpp:231 +msgid "Exit rekonq if last tab closed" +msgstr "" + +#. i18n: file: settings_ui.ui:41 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_alwaysShowTabBar) +#: rc.cpp:234 +msgid "Always show TabBar" msgstr "" diff --git a/po/rekonq_ru.po b/po/rekonq_ru.po new file mode 100644 index 00000000..4e9c5873 --- /dev/null +++ b/po/rekonq_ru.po @@ -0,0 +1,750 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the rekonq package. +# FIRST AUTHOR Domrachev Alexandr , 2009. +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?\n" +"POT-Creation-Date: 2009-03-28 23:04+0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator:Domrachev Alexandr \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Language: ru_RU\n" + +#: cookiejar.cpp:472 cookiejar.cpp:651 +msgid "Website" +msgstr "" + +#: cookiejar.cpp:474 +msgid "Name" +msgstr "" + +#: cookiejar.cpp:476 +msgid "Path" +msgstr "" + +#: cookiejar.cpp:478 +msgid "Secure" +msgstr "" + +#: cookiejar.cpp:480 +msgid "Expires" +msgstr "" + +#: cookiejar.cpp:482 +msgid "Contents" +msgstr "" + +#: cookiejar.cpp:653 +msgid "Status" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:77 +#. i18n: ectx: property (text), widget (QPushButton, allowButton) +#: cookiejar.cpp:678 rc.cpp:18 +msgid "Allow" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:57 +#. i18n: ectx: property (text), widget (QPushButton, blockButton) +#: cookiejar.cpp:689 rc.cpp:12 +msgid "Block" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:67 +#. i18n: ectx: property (text), widget (QPushButton, allowForSessionButton) +#: cookiejar.cpp:700 rc.cpp:15 +msgid "Allow For Session" +msgstr "" + +#: history.cpp:422 +msgid "Title" +msgstr "" + +#: history.cpp:423 +msgid "Address" +msgstr "" + +#: history.cpp:680 +msgid "Show All History" +msgstr "" + +#: history.cpp:684 +msgid "Clear History" +msgstr "Очистить журнал" + +#: history.cpp:765 +msgid "Open" +msgstr "Открыть" + +#: history.cpp:767 +msgid "Copy" +msgstr "Копировать" + +#: history.cpp:769 +msgid "Delete" +msgstr "Удалить" + +#: history.cpp:1152 +msgid "Earlier Today" +msgstr "" + +#: history.cpp:1157 +msgid " items" +msgstr "" + +#: main.cpp:29 +msgid "KDE Browser Webkit Based" +msgstr "" + +#: main.cpp:39 +msgid "rekonq" +msgstr "" + +#: main.cpp:43 +msgid "(C) 2008 Andrea Diamantini" +msgstr "" + +#: main.cpp:49 +msgid "Andrea Diamantini" +msgstr "" + +#: main.cpp:57 +msgid "Location to open" +msgstr "" + +#: mainview.cpp:77 +msgid "Recently Closed Tabs" +msgstr "Недавно закрытые вкладки" + +#: mainview.cpp:370 mainview.cpp:395 +msgid "(Untitled)" +msgstr "" + +#: mainview.cpp:491 +msgid "" +"You have modified this page and when closing it you would lose the " +"modification.\n" +"Do you really want to close this page?\n" +msgstr "" + +#: mainview.cpp:493 +msgid "Do you really want to close this page?" +msgstr "Вы действительно хотите закрыть эту страницу?" + +#: mainwindow.cpp:113 +msgid "B&ookmarks" +msgstr "&Закладки" + +#: mainwindow.cpp:190 +#, fuzzy +msgid "&Stop" +msgstr "&Стоп" + +#: mainwindow.cpp:196 +msgid "reload" +msgstr "" + +#: mainwindow.cpp:200 +msgid "Open Location" +msgstr "" + +#: mainwindow.cpp:204 +msgid "Private &Browsing..." +msgstr "" + +#: mainwindow.cpp:206 +msgid "private browsing" +msgstr "" + +#: mainwindow.cpp:209 +msgid "&Enlarge Font" +msgstr "У&величить шрифт" + +#: mainwindow.cpp:214 +msgid "&Normal Font" +msgstr "&Нормальный шрифт" + +#: mainwindow.cpp:219 +msgid "&Shrink Font" +msgstr "У&меньшить шрифт" + +#: mainwindow.cpp:224 +msgid "Page S&ource" +msgstr "" + +#: mainwindow.cpp:228 +msgid "Enable Web &Inspector" +msgstr "" + +#: mainwindow.cpp:234 +msgid "Back" +msgstr "" + +#: mainwindow.cpp:243 +msgid "Forward" +msgstr "" + +#: mainwindow.cpp:248 tabbar.cpp:101 +msgid "New &Tab" +msgstr "Новая &вкладка" + +#: mainwindow.cpp:253 tabbar.cpp:109 +msgid "&Close Tab" +msgstr "&Закрыть вкладку" + +#: mainwindow.cpp:258 +msgid "Show Next Tab" +msgstr "Открыть следующую вкладку" + +#: mainwindow.cpp:263 +msgid "Show Previous Tab" +msgstr "" + +#: mainwindow.cpp:293 +#, fuzzy +msgid "&History" +msgstr "Журнал" + +#: mainwindow.cpp:476 +msgid "Web Resources (*.html *.htm *.svg *.png *.gif *.svgz);;All files (*.*)" +msgstr "" + +#: mainwindow.cpp:478 +msgid "Open Web Resource" +msgstr "" + +#: mainwindow.cpp:510 +msgid "Print Document" +msgstr "" + +#: mainwindow.cpp:523 +msgid "Are you sure you want to turn on private browsing?" +msgstr "Вы действительно хотите включить режим конфиденциальности?" + +#: mainwindow.cpp:524 +msgid "" +"

    When private browsing in turned on, webpages are not added to " +"the history, items are automatically removed from the Downloads window, new " +"cookies are not stored, current cookies can't be accessed, site icons wont " +"be stored, session wont be saved, and searches are not addded to the pop-up " +"menu in the Google search box. Until you close the window, you can still " +"click the Back and Forward buttons to return to the webpages you have opened." +msgstr "" + +#: mainwindow.cpp:590 mainwindow.cpp:601 +#, fuzzy +msgid " not found." +msgstr "не найдено." + +#: mainwindow.cpp:654 +msgid "Page Source of " +msgstr "" + +#: mainwindow.cpp:673 +msgid "" +"The web inspector will only work correctly for pages that were loaded after " +"enabling.\n" +"Do you want to reload all pages?" +msgstr "" + +#: mainwindow.cpp:675 +msgid "Web Inspector" +msgstr "" + +#: mainwindow.cpp:719 +msgid "Stop loading the current page" +msgstr "Остановить загрузку страницы" + +#: mainwindow.cpp:720 +msgid "Stop" +msgstr "" + +#: mainwindow.cpp:727 +msgid "Reload the current page" +msgstr "Обновить страницу" + +#: mainwindow.cpp:728 +msgid "Reload" +msgstr "Обновить" + +#: networkaccessmanager.cpp:116 +msgid "Enter username and password for " +msgstr "Введите имя пользователя и пароль для " + +#: networkaccessmanager.cpp:117 +msgid " at " +msgstr "" + +#: networkaccessmanager.cpp:141 +msgid "Connect to proxy " +msgstr "" + +#: networkaccessmanager.cpp:141 +msgid " using:" +msgstr "" + +#: networkaccessmanager.cpp:161 +msgid "" +"SSL Errors:\n" +"\n" +msgstr "" + +#: searchbar.cpp:55 +msgid "Search.." +msgstr "Поиск..." + +#. i18n: file: settings_general.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, general) +#: settings.cpp:80 rc.cpp:111 +msgid "General" +msgstr "" + +#. i18n: file: settings_fonts.ui:20 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox) +#: settings.cpp:86 rc.cpp:96 +msgid "Fonts" +msgstr "Шрифты" + +#. i18n: file: settings_privacy.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, privacy) +#: settings.cpp:92 rc.cpp:135 +msgid "Privacy" +msgstr "" + +#. i18n: file: settings_proxy.ui:13 +#. i18n: ectx: property (windowTitle), widget (QWidget, proxy) +#: settings.cpp:98 rc.cpp:195 +msgid "Proxy" +msgstr "" + +#: settings.cpp:104 +msgid "Interface" +msgstr "Интерфейс" + +#: settings.cpp:117 +msgid "rekonfig.." +msgstr "" + +#: tabbar.cpp:107 +msgid "Clone Tab" +msgstr "" + +#: tabbar.cpp:110 +msgid "Close &Other Tabs" +msgstr "" + +#: tabbar.cpp:112 +msgid "Reload Tab" +msgstr "Обновить вкладку" + +#: tabbar.cpp:118 +msgid "Reload All Tabs" +msgstr "Обновить все вкладки" + +#: webview.cpp:163 +msgid "Error loading page: " +msgstr "" + +#: webview.cpp:221 +msgid "Open in New Tab" +msgstr "Открыть в новой вкладке" + +#. i18n: file: cookiesexceptions.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, CookiesExceptionsDialog) +#: rc.cpp:3 +msgid "Cookie Exceptions" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:19 +#. i18n: ectx: property (title), widget (QGroupBox, newExceptionGroupBox) +#: rc.cpp:6 +msgid "New Exception" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:27 +#. i18n: ectx: property (text), widget (QLabel, label) +#: rc.cpp:9 +msgid "Domain:" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:89 +#. i18n: ectx: property (title), widget (QGroupBox, ExceptionsGroupBox) +#: rc.cpp:21 +msgid "Exceptions" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:114 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#. i18n: file: cookies.ui:41 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#. i18n: file: history.ui:40 +#. i18n: ectx: property (text), widget (QPushButton, removeButton) +#: rc.cpp:24 rc.cpp:33 rc.cpp:42 +msgid "&Remove" +msgstr "" + +#. i18n: file: cookiesexceptions.ui:121 +#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) +#. i18n: file: history.ui:47 +#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) +#: rc.cpp:27 rc.cpp:45 +msgid "Remove &All" +msgstr "" + +#. i18n: file: cookies.ui:14 +#. i18n: ectx: property (windowTitle), widget (QDialog, CookiesDialog) +#. i18n: file: settings_privacy.ui:73 +#. i18n: ectx: property (title), widget (QGroupBox, cookiesGroupBox) +#: rc.cpp:30 rc.cpp:162 +msgid "Cookies" +msgstr "" + +#. i18n: file: cookies.ui:48 +#. i18n: ectx: property (text), widget (QPushButton, removeAllButton) +#: rc.cpp:36 +msgid "Remove &All Cookies" +msgstr "" + +#. i18n: file: history.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, HistoryDialog) +#. i18n: file: settings_privacy.ui:20 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) +#: rc.cpp:39 rc.cpp:138 +msgid "History" +msgstr "Журнал" + +#. i18n: file: passworddialog.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, PasswordDialog) +#: rc.cpp:48 +msgid "Authentication Required" +msgstr "" + +#. i18n: file: passworddialog.ui:21 +#. i18n: ectx: property (text), widget (QLabel, iconLabel) +#: rc.cpp:51 +msgid "DUMMY ICON" +msgstr "" + +#. i18n: file: passworddialog.ui:34 +#. i18n: ectx: property (text), widget (QLabel, introLabel) +#: rc.cpp:54 +msgid "INTRO TEXT DUMMY" +msgstr "" + +#. i18n: file: passworddialog.ui:43 +#. i18n: ectx: property (text), widget (QLabel, label) +#. i18n: file: proxy.ui:36 +#. i18n: ectx: property (text), widget (QLabel, usernameLabel) +#: rc.cpp:57 rc.cpp:72 +msgid "Username:" +msgstr "" + +#. i18n: file: passworddialog.ui:53 +#. i18n: ectx: property (text), widget (QLabel, lblPassword) +#. i18n: file: proxy.ui:46 +#. i18n: ectx: property (text), widget (QLabel, passwordLabel) +#. i18n: file: settings_proxy.ui:115 +#. i18n: ectx: property (text), widget (QLabel, label_13) +#: rc.cpp:60 rc.cpp:75 rc.cpp:222 +msgid "Password:" +msgstr "" + +#. i18n: file: proxy.ui:13 +#. i18n: ectx: property (windowTitle), widget (QDialog, ProxyDialog) +#: rc.cpp:63 +msgid "Proxy Authentication" +msgstr "" + +#. i18n: file: proxy.ui:19 +#. i18n: ectx: property (text), widget (QLabel, iconLabel) +#: rc.cpp:66 +msgid "ICON" +msgstr "" + +#. i18n: file: proxy.ui:26 +#. i18n: ectx: property (text), widget (QLabel, introLabel) +#: rc.cpp:69 +msgid "Connect to proxy" +msgstr "" + +#. i18n: file: rekonqui.rc:8 +#. i18n: ectx: Menu (file) +#: rc.cpp:78 +msgid "&File" +msgstr "&Файл" + +#. i18n: file: rekonqui.rc:27 +#. i18n: ectx: Menu (edit) +#: rc.cpp:81 +msgid "&Edit" +msgstr "&Правка" + +#. i18n: file: rekonqui.rc:41 +#. i18n: ectx: Menu (view) +#: rc.cpp:84 +msgid "&View" +msgstr "&Вид" + +#. i18n: file: rekonqui.rc:71 +#. i18n: ectx: ToolBar (mainToolBar) +#: rc.cpp:87 +msgid "Main Toolbar" +msgstr "Панель инструментов" + +#. i18n: file: rekonqui.rc:80 +#. i18n: ectx: ToolBar (bookmarksToolBar) +#: rc.cpp:90 +msgid "Bookmark Toolbar" +msgstr "Панель закладок" + +#. i18n: file: settings_fonts.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, fonts) +#: rc.cpp:93 +msgid "Appearance" +msgstr "" + +#. i18n: file: settings_fonts.ui:28 +#. i18n: ectx: property (text), widget (QLabel, label) +#: rc.cpp:99 +msgid "Standard Font" +msgstr "Стандартный шрифт" + +#. i18n: file: settings_fonts.ui:35 +#. i18n: ectx: property (text), widget (QLabel, label_2) +#: rc.cpp:102 +msgid "Fixed Font" +msgstr "Моноширинный шрифт" + +#. i18n: file: settings_fonts.ui:53 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) +#: rc.cpp:105 +msgid "Dimension" +msgstr "" + +#. i18n: file: settings_fonts.ui:61 +#. i18n: ectx: property (text), widget (QLabel, label_3) +#: rc.cpp:108 +msgid "Font Size" +msgstr "" + +#. i18n: file: settings_general.ui:20 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox) +#: rc.cpp:114 +msgid "Places" +msgstr "" + +#. i18n: file: settings_general.ui:26 +#. i18n: ectx: property (text), widget (QLabel, label_3) +#: rc.cpp:117 +msgid "Home:" +msgstr "" + +#. i18n: file: settings_general.ui:48 +#. i18n: ectx: property (text), widget (QPushButton, setHomeToCurrentPageButton) +#: rc.cpp:120 +msgid "Set to current page" +msgstr "Использовать текущую страницу" + +#. i18n: file: settings_general.ui:73 +#. i18n: ectx: property (text), widget (QLabel, label_7) +#: rc.cpp:123 +msgid "Save downloads to:" +msgstr "Загружать файлы в:" + +#. i18n: file: settings_general.ui:86 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox_2) +#: rc.cpp:126 +msgid "Web Content" +msgstr "" + +#. i18n: file: settings_general.ui:92 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_enablePlugins) +#: rc.cpp:129 +msgid "Enable Plugins" +msgstr "Включить плагины" + +#. i18n: file: settings_general.ui:102 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_enableJavascript) +#: rc.cpp:132 +msgid "Enable Javascript" +msgstr "Включить Javascript" + +#. i18n: file: settings_privacy.ui:26 +#. i18n: ectx: property (text), widget (QLabel, label_4) +#: rc.cpp:141 +msgid "Remove history items:" +msgstr "" + +#. i18n: file: settings_privacy.ui:37 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:144 +msgid "After one day" +msgstr "" + +#. i18n: file: settings_privacy.ui:42 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:147 +msgid "After one week" +msgstr "" + +#. i18n: file: settings_privacy.ui:47 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:150 +msgid "After two weeks" +msgstr "" + +#. i18n: file: settings_privacy.ui:52 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:153 +msgid "After one month" +msgstr "" + +#. i18n: file: settings_privacy.ui:57 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:156 +msgid "After one year" +msgstr "" + +#. i18n: file: settings_privacy.ui:62 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_expireHistory) +#: rc.cpp:159 +msgid "Manually" +msgstr "" + +#. i18n: file: settings_privacy.ui:79 +#. i18n: ectx: property (text), widget (QLabel, label_2) +#: rc.cpp:165 +msgid "Accept Cookies:" +msgstr "" + +#. i18n: file: settings_privacy.ui:90 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) +#: rc.cpp:168 +msgid "Always" +msgstr "" + +#. i18n: file: settings_privacy.ui:95 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) +#: rc.cpp:171 +msgid "Never" +msgstr "" + +#. i18n: file: settings_privacy.ui:100 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_acceptCookies) +#: rc.cpp:174 +msgid "Only from sites you navigate to" +msgstr "" + +#. i18n: file: settings_privacy.ui:108 +#. i18n: ectx: property (text), widget (QPushButton, exceptionsButton) +#: rc.cpp:177 +msgid "Exceptions..." +msgstr "" + +#. i18n: file: settings_privacy.ui:115 +#. i18n: ectx: property (text), widget (QLabel, label) +#: rc.cpp:180 +msgid "Keep until:" +msgstr "" + +#. i18n: file: settings_privacy.ui:126 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) +#: rc.cpp:183 +msgid "They expire" +msgstr "" + +#. i18n: file: settings_privacy.ui:131 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) +#: rc.cpp:186 +msgid "I exit the application" +msgstr "" + +#. i18n: file: settings_privacy.ui:136 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_keepCookiesUntil) +#: rc.cpp:189 +msgid "At most 90 days" +msgstr "" + +#. i18n: file: settings_privacy.ui:144 +#. i18n: ectx: property (text), widget (QPushButton, cookiesButton) +#: rc.cpp:192 +msgid "Cookies..." +msgstr "" + +#. i18n: file: settings_proxy.ui:19 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_isProxyEnabled) +#: rc.cpp:198 +msgid "enable proxy" +msgstr "" + +#. i18n: file: settings_proxy.ui:26 +#. i18n: ectx: property (title), widget (QGroupBox, groupBox) +#: rc.cpp:201 +msgid "Proxy Settings" +msgstr "Нстройки proxy" + +#. i18n: file: settings_proxy.ui:32 +#. i18n: ectx: property (text), widget (QLabel, label_9) +#: rc.cpp:204 +msgid "Type:" +msgstr "" + +#. i18n: file: settings_proxy.ui:43 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_proxyType) +#: rc.cpp:207 +msgid "Socks5" +msgstr "" + +#. i18n: file: settings_proxy.ui:48 +#. i18n: ectx: property (text), item, widget (QComboBox, kcfg_proxyType) +#: rc.cpp:210 +msgid "Http" +msgstr "" + +#. i18n: file: settings_proxy.ui:56 +#. i18n: ectx: property (text), widget (QLabel, label_10) +#: rc.cpp:213 +msgid "Host:" +msgstr "" + +#. i18n: file: settings_proxy.ui:69 +#. i18n: ectx: property (text), widget (QLabel, label_11) +#: rc.cpp:216 +msgid "Port:" +msgstr "" + +#. i18n: file: settings_proxy.ui:102 +#. i18n: ectx: property (text), widget (QLabel, label_12) +#: rc.cpp:219 +msgid "User Name:" +msgstr "" + +#. i18n: file: settings_ui.ui:14 +#. i18n: ectx: property (windowTitle), widget (QWidget, ui) +#: rc.cpp:225 +msgid "Ui" +msgstr "" + +#. i18n: file: settings_ui.ui:20 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_enableLocationbarProgressIndicator) +#: rc.cpp:228 +msgid "Enable location bar progress indication" +msgstr "Показывать индикатор загрузки страницы в адресной строке" + +#. i18n: file: settings_ui.ui:34 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_closeWithLastTab) +#: rc.cpp:231 +msgid "Exit rekonq if last tab closed" +msgstr "Выходить из rekonq при закрытии последней вкладки" + +#. i18n: file: settings_ui.ui:41 +#. i18n: ectx: property (text), widget (QCheckBox, kcfg_alwaysShowTabBar) +#: rc.cpp:234 +msgid "Always show TabBar" +msgstr "Всегда показывать панель вкладок" diff --git a/scripts/Messages.sh b/scripts/Messages.sh index 09ce1214..e9b5444d 100755 --- a/scripts/Messages.sh +++ b/scripts/Messages.sh @@ -1,5 +1,41 @@ -# FIXME #! /usr/bin/env bash -$EXTRACTRC `find . -name \*.ui -o -name \*.rc -o -name \*.kcfg` >> rc.cpp -$XGETTEXT `find . -name \*.cpp` -o $podir/rekonq.pot + +BASEDIR="../src/" +PROJECT="rekonq" +BUGADDR="http://sourceforge.net/tracker/?group_id=252277&atid=1126949" +WDIR="../po/" + +cd ${BASEDIR} +echo "Preparing rc files" +find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list +xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp +cd ${WDIR} +echo "Done preparing rc files" + +echo "Extracting messages" +cd ${BASEDIR} +find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | sort > ${WDIR}/infiles.list +echo "rc.cpp" >> ${WDIR}/infiles.list +cd ${WDIR} +xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \ + -kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \ + --msgid-bugs-address="${BUGADDR}" \ + --files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; } +echo "Done extracting messages" + +echo "Merging translations" +catalogs=`find . -name '*.po'` +for cat in $catalogs; do + echo $cat + msgmerge -o $cat.new $cat ${PROJECT}.pot + mv $cat.new $cat +done +echo "Done merging translations" + +echo "Cleaning up" +cd ${WDIR} +rm rcfiles.list +rm infiles.list +rm rc.cpp +echo "Done" -- cgit v1.2.1 From 5b51443760b056fbe966984072c96c2a85c98f9b Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 00:25:30 +0100 Subject: updated TODO --- TODO | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index c9d47122..f61d5065 100644 --- a/TODO +++ b/TODO @@ -7,13 +7,13 @@ DONE Added Google Suggestions DONE notfound.html shown if rekonq doesn't load connection DONE improve fullscreen DONE QNetworkDiskCache +DONE loading right sites as "external browser" (rekonq %u) +DONE provide translations structure +DONE disable BACK button when history is NULL - QWebFrame DONE(?) definitely fix fonts! - fix crash on example sites.. - load just ONE site at start -- loading right sites as "external browser" -- provide translations -- disable BACK button when history is NULL - improve DOCUMENTATION -- cgit v1.2.1 From 5ee1c2f7d46f7a7cd2ab34c16f4ff185b94cc1a2 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 00:56:37 +0100 Subject: Load just 1 site at start.. --- TODO | 3 ++- src/application.cpp | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index f61d5065..300de9cd 100644 --- a/TODO +++ b/TODO @@ -10,10 +10,11 @@ DONE QNetworkDiskCache DONE loading right sites as "external browser" (rekonq %u) DONE provide translations structure DONE disable BACK button when history is NULL +DONE load just ONE site at start - QWebFrame DONE(?) definitely fix fonts! - fix crash on example sites.. -- load just ONE site at start + - improve DOCUMENTATION diff --git a/src/application.cpp b/src/application.cpp index 53b1cbce..0151d364 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -65,7 +65,6 @@ Application::Application() m_mainWindow->setObjectName("MainWindow"); setWindowIcon(KIcon("rekonq")); newTab(); - mainWindow()->slotHome(); m_mainWindow->show(); @@ -87,7 +86,9 @@ int Application::newInstance() if (args->count() > 0) { - for (int i = 0; i < args->count(); ++i) + KUrl url = MainWindow::guessUrlFromString(args->arg(0)); + mainWindow()->loadUrl(url); + for (int i = 1; i < args->count(); ++i) { KUrl url = MainWindow::guessUrlFromString(args->arg(i)); newTab(); @@ -95,6 +96,10 @@ int Application::newInstance() } args->clear(); } + else + { + mainWindow()->slotHome(); + } return 0; } @@ -161,7 +166,6 @@ NetworkAccessManager *Application::networkAccessManager() } - HistoryManager *Application::historyManager() { if (!s_historyManager) -- cgit v1.2.1 From fb023c2a61537aba8684ec06aad76b206ce08440 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 07:43:05 +0200 Subject: DBUS service name --- data/rekonq.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/data/rekonq.desktop b/data/rekonq.desktop index 2e9995dc..df150fee 100644 --- a/data/rekonq.desktop +++ b/data/rekonq.desktop @@ -8,3 +8,4 @@ DocPath=rekonq/index.html Categories=Qt;KDE;Network; Terminal=0 X-DBUS-StartupType=Unique +X-DBUS-ServiceName=net.sourceforge.rekonq -- cgit v1.2.1 From 76ff257898ea60c37cb20cff320d7c747c4a8b3c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 07:49:41 +0200 Subject: Search wrap --- src/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ed347bef..c459fc42 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -596,7 +596,7 @@ void MainWindow::slotFindPrevious() { if (!currentTab() && m_lastSearch.isEmpty()) return; - if (!currentTab()->findText(m_lastSearch, QWebPage::FindBackward)) + if (!currentTab()->findText(m_lastSearch, QWebPage::FindBackward | QWebPage::FindWrapsAroundDocument)) { slotUpdateStatusbar(QString(m_lastSearch) + i18n(" not found.")); } -- cgit v1.2.1 From 0b151ba388d46c4112b4e861d45f0d8229c8a599 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 29 Mar 2009 08:04:31 +0200 Subject: API change (rename). In MainView, newTab --> newWebView --- src/application.cpp | 8 ++++---- src/application.h | 2 +- src/mainview.cpp | 12 ++++++------ src/mainview.h | 2 +- src/mainwindow.cpp | 6 +++--- src/webview.cpp | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 0151d364..3ff931e4 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -64,7 +64,7 @@ Application::Application() m_mainWindow = new MainWindow(); m_mainWindow->setObjectName("MainWindow"); setWindowIcon(KIcon("rekonq")); - newTab(); + newWebView(); m_mainWindow->show(); @@ -91,7 +91,7 @@ int Application::newInstance() for (int i = 1; i < args->count(); ++i) { KUrl url = MainWindow::guessUrlFromString(args->arg(i)); - newTab(); + newWebView(); mainWindow()->loadUrl(url); } args->clear(); @@ -143,9 +143,9 @@ MainWindow *Application::mainWindow() } -WebView *Application::newTab() +WebView *Application::newWebView() { - return m_mainWindow->mainView()->newTab(); + return m_mainWindow->mainView()->newWebView(); } diff --git a/src/application.h b/src/application.h index fa731c4e..654d554f 100644 --- a/src/application.h +++ b/src/application.h @@ -52,7 +52,7 @@ public: static Application *instance(); MainWindow *mainWindow(); - WebView* newTab(); + WebView* newWebView(); KIcon icon(const KUrl &url) const; diff --git a/src/mainview.cpp b/src/mainview.cpp index 4ab8dc8b..3c563230 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -61,7 +61,7 @@ MainView::MainView(QWidget *parent) { setTabBar(m_tabBar); - connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newTab())); + connect(m_tabBar, SIGNAL(newTab()), this, SLOT(newWebView())); connect(m_tabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int))); connect(m_tabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int))); connect(m_tabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int))); @@ -317,7 +317,7 @@ WebView *MainView::webView(int index) const { MainView *that = const_cast(this); that->setUpdatesEnabled(false); - that->newTab(); + that->newWebView(); that->closeTab(0); that->setUpdatesEnabled(true); return currentWebView(); @@ -334,7 +334,7 @@ int MainView::webViewIndex(WebView *webView) const } -WebView *MainView::newTab(bool makeCurrent) +WebView *MainView::newWebView(bool makeCurrent) { // line edit UrlBar *urlLineEdit = new UrlBar; @@ -465,7 +465,7 @@ void MainView::cloneTab(int index) index = currentIndex(); if (index < 0 || index >= count()) return; - WebView *tab = newTab(false); + WebView *tab = newWebView(false); tab->setUrl(webView(index)->url()); showTabBar(); @@ -593,7 +593,7 @@ void MainView::mouseDoubleClickEvent(QMouseEvent *event) // Remove the line below when QTabWidget does not have a one pixel frame && event->pos().y() < (tabBar()->y() + tabBar()->height())) { - newTab(); + newWebView(); return; } KTabWidget::mouseDoubleClickEvent(event); @@ -620,7 +620,7 @@ void MainView::mouseReleaseEvent(QMouseEvent *event) KUrl url(QApplication::clipboard()->text(QClipboard::Selection)); if (!url.isEmpty() && url.isValid() && !url.scheme().isEmpty()) { - WebView *webView = newTab(); + WebView *webView = newWebView(); webView->setUrl(url); } } diff --git a/src/mainview.h b/src/mainview.h index 4e2d8b6e..56808c02 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -102,7 +102,7 @@ protected: public slots: void loadUrlInCurrentTab(const KUrl &url); - WebView *newTab(bool makeCurrent = true); + WebView *newWebView(bool makeCurrent = true); void cloneTab(int index = -1); void closeTab(int index = -1); void closeOtherTabs(int index); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c459fc42..2a5f9295 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -99,7 +99,7 @@ MainWindow::MainWindow() connect(m_view, SIGNAL(printRequested(QWebFrame *)), this, SLOT(printRequested(QWebFrame *))); connect(m_view, SIGNAL(menuBarVisibilityChangeRequested(bool)), menuBar(), SLOT(setVisible(bool))); connect(m_view, SIGNAL(statusBarVisibilityChangeRequested(bool)), statusBar(), SLOT(setVisible(bool))); - connect(m_view, SIGNAL(lastTabClosed()), m_view, SLOT(newTab())); + connect(m_view, SIGNAL(lastTabClosed()), m_view, SLOT(newWebView())); connect(m_view, SIGNAL(tabsChanged()), this, SLOT(slotUpdateActions())); connect(m_view, SIGNAL(currentChanged(int)), this, SLOT(slotUpdateActions())); @@ -251,7 +251,7 @@ void MainWindow::setupActions() a = new KAction(KIcon("tab-new"), i18n("New &Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_N, Qt::CTRL + Qt::Key_T)); actionCollection()->addAction(QLatin1String("new_tab"), a); - connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newTab())); + connect(a, SIGNAL(triggered(bool)), m_view, SLOT(newWebView())); a = new KAction(KIcon("tab-close"), i18n("&Close Tab"), this); a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_W)); @@ -465,7 +465,7 @@ void MainWindow::slotUpdateWindowTitle(const QString &title) void MainWindow::slotFileNew() { - Application::instance()->newTab(); + Application::instance()->newWebView(); slotHome(); } diff --git a/src/webview.cpp b/src/webview.cpp index 239a5f5a..35444f42 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -84,7 +84,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if (type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton)) { - WebView *webView = Application::instance()->newTab(); + WebView *webView = Application::instance()->newWebView(); webView->setFocus(); webView->load(request); m_keyboardModifiers = Qt::NoModifier; @@ -122,7 +122,7 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) if (m_openInNewTab) { m_openInNewTab = false; - return mainWindow()->mainView()->newTab()->page(); + return mainWindow()->mainView()->newWebView()->page(); } MainWindow *mainWindow = Application::instance()->mainWindow(); -- cgit v1.2.1 From a6b98be2ac1fd83d7d450d7d8a9e35687aa44686 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Mon, 30 Mar 2009 11:16:19 +0200 Subject: opening new tabs on target _blank. Try 1 --- src/webview.cpp | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/webview.cpp b/src/webview.cpp index 35444f42..07cf4b53 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -58,7 +58,6 @@ WebPage::WebPage(QObject *parent) WebPage::~WebPage() { - } @@ -75,22 +74,28 @@ MainWindow *WebPage::mainWindow() } +// FIXME load links (target _blank) in new tabs!! bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { kWarning() << "Accepting Navigation Request.."; // ctrl open in new tab and select - // ctrl-alt open in new window - if (type == QWebPage::NavigationTypeLinkClicked && (m_keyboardModifiers & Qt::ControlModifier - || m_pressedButtons == Qt::MidButton)) + if (type == QWebPage::NavigationTypeLinkClicked) { - WebView *webView = Application::instance()->newWebView(); - webView->setFocus(); - webView->load(request); - m_keyboardModifiers = Qt::NoModifier; - m_pressedButtons = Qt::NoButton; - return false; + kWarning() << "Navigation Type LINKCLICKED.."; + + if(m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) + { + kWarning() << "ControlModifiers clicked.."; + WebView *webView = Application::instance()->newWebView(); + webView->setFocus(); + webView->load(request); + m_keyboardModifiers = Qt::NoModifier; + m_pressedButtons = Qt::NoButton; + return false; + } } + if (frame == mainFrame()) { m_loadingUrl = request.url(); @@ -98,9 +103,18 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r } else { - kWarning() << "NO Main Frame.."; - kWarning() << "Frame : " << frame->frameName(); + kWarning() << "NO Main Frame, creating a new WebView.."; + WebView *webView = Application::instance()->newWebView(); + webView->setFocus(); + webView->load(request); + return false; } + + if(type == QWebPage::NavigationTypeOther) + { + kWarning() << "Navigation Type OTHER.."; + } + return QWebPage::acceptNavigationRequest(frame, request, type); } @@ -110,7 +124,8 @@ QWebPage *WebPage::createWindow(QWebPage::WebWindowType type) // added to manage web modal dialogs if (type == QWebPage::WebModalDialog) { - WebView *w = new WebView; + kWarning() << "prova QWebView ------------------------------------------------------"; + QWebView *w = new QWebView; return w->page(); } @@ -253,6 +268,7 @@ void WebView::wheelEvent(QWheelEvent *event) void WebView::openLinkInNewTab() { m_page->m_openInNewTab = true; + kWarning() << "NO panic..."; pageAction(QWebPage::OpenLinkInNewWindow)->trigger(); } -- cgit v1.2.1 From 586f23eac0773453a5718758db7bf57b96336605 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 31 Mar 2009 01:49:41 +0200 Subject: Properly opening mailto links --- src/webview.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/webview.cpp b/src/webview.cpp index 07cf4b53..c3ad49b3 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -79,6 +79,13 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r { kWarning() << "Accepting Navigation Request.."; + QString scheme = request.url().scheme(); + if (scheme == QLatin1String("mailto") ) + { + QDesktopServices::openUrl(request.url()); + return false; + } + // ctrl open in new tab and select if (type == QWebPage::NavigationTypeLinkClicked) { -- cgit v1.2.1 From 6d7c51718b098d81d19719376d91c9a97285a48f Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 31 Mar 2009 02:02:15 +0200 Subject: Rewritten acceptNavigationRequest code --- src/webview.cpp | 67 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/src/webview.cpp b/src/webview.cpp index c3ad49b3..0e9a3c9d 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -86,9 +86,12 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r return false; } - // ctrl open in new tab and select - if (type == QWebPage::NavigationTypeLinkClicked) + switch(type) { + + // user clicked on a link or pressed return on a focused link. + case QWebPage::NavigationTypeLinkClicked: + kWarning() << "Navigation Type LINKCLICKED.."; if(m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) @@ -101,25 +104,51 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r m_pressedButtons = Qt::NoButton; return false; } - } - - if (frame == mainFrame()) - { - m_loadingUrl = request.url(); - emit loadingUrl(m_loadingUrl); - } - else - { - kWarning() << "NO Main Frame, creating a new WebView.."; - WebView *webView = Application::instance()->newWebView(); - webView->setFocus(); - webView->load(request); - return false; - } - if(type == QWebPage::NavigationTypeOther) - { + if (frame == mainFrame()) + { + m_loadingUrl = request.url(); + emit loadingUrl(m_loadingUrl); + } + else + { + kWarning() << "NO Main Frame, creating a new WebView.."; + WebView *webView = Application::instance()->newWebView(); + webView->setFocus(); + webView->load(request); + return false; + } + break; + + // user activated a submit button for an HTML form. + case QWebPage::NavigationTypeFormSubmitted: + kWarning() << "Navigation Type Form Submitted.."; + break; + + // Navigation to a previously shown document in the back or forward history is requested. + case QWebPage::NavigationTypeBackOrForward: + kWarning() << "Navigation Type BackOrForward.."; + break; + + // user activated the reload action. + case QWebPage::NavigationTypeReload: + kWarning() << "Navigation Type Reload.."; + break; + + // An HTML form was submitted a second time. + case QWebPage::NavigationTypeFormResubmitted: + kWarning() << "Navigation Type Form Resubmitted.."; + break; + + // A navigation to another document using a method not listed above. + case QWebPage::NavigationTypeOther: kWarning() << "Navigation Type OTHER.."; + break; + + // should be nothing.. + default: + kWarning() << "Default NON existant case.."; + break; } return QWebPage::acceptNavigationRequest(frame, request, type); -- cgit v1.2.1 From 1a8dee308d05455e05c4fcc617f4e7a9acea998a Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 31 Mar 2009 02:02:47 +0200 Subject: removed FIXME --- src/webview.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/webview.cpp b/src/webview.cpp index 0e9a3c9d..7096d850 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -74,7 +74,6 @@ MainWindow *WebPage::mainWindow() } -// FIXME load links (target _blank) in new tabs!! bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) { kWarning() << "Accepting Navigation Request.."; -- cgit v1.2.1 From f44c5c0a8883d265256ae943623dfc9680741f30 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 31 Mar 2009 02:24:54 +0200 Subject: code fixing --- src/webview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/webview.cpp b/src/webview.cpp index 7096d850..1057a5ef 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -85,6 +85,8 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r return false; } + WebView *webView; + switch(type) { @@ -96,7 +98,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if(m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) { kWarning() << "ControlModifiers clicked.."; - WebView *webView = Application::instance()->newWebView(); + webView = Application::instance()->newWebView(); webView->setFocus(); webView->load(request); m_keyboardModifiers = Qt::NoModifier; @@ -112,7 +114,7 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r else { kWarning() << "NO Main Frame, creating a new WebView.."; - WebView *webView = Application::instance()->newWebView(); + webView = Application::instance()->newWebView(); webView->setFocus(); webView->load(request); return false; -- cgit v1.2.1 From f3875c6127551a36bfa6328f720bd958681e7f82 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 31 Mar 2009 02:32:58 +0200 Subject: updated TODO --- TODO | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/TODO b/TODO index 300de9cd..5e7ff488 100644 --- a/TODO +++ b/TODO @@ -17,32 +17,10 @@ DONE(?) definitely fix fonts! - improve DOCUMENTATION - -To 0.0.4 -- improve DOCUMENTATION -- fix docs -- autosave-- -- dbus support -- new application class!! -- improve bookmarks toolbar -- fix KConfigXT (fonts) -- color url_line_edit progress -- contextMenu in searchbar to set different search engines -- KDE proxy support -- QWebPluginFactory subclass to load KParts into QtWebKit. - - + ------------------------ - -1. check the lines above... -2. Improve docs -DONE. Let rekonq be a Singleton app. (And work well..) -DONE. fix bookmarks toolbar POSITION -5. fix bookmarks action menu (in toolbar) -DONE. fix load at startup -DONE. fix FONTS problems between webkit && KDE settings (at least, here..) -DONE. enable flash support !! - - -+ ------------------------ +LONG TERM FIXES +- Page source (to be decided) +- cookies +- history (io-slave) +- -- cgit v1.2.1 From e52d6356917bde5c2cf7441c53074095c6e2823e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 31 Mar 2009 02:34:49 +0200 Subject: updated TODO. 2 --- TODO | 1 + 1 file changed, 1 insertion(+) diff --git a/TODO b/TODO index 5e7ff488..49ee0a58 100644 --- a/TODO +++ b/TODO @@ -23,4 +23,5 @@ LONG TERM FIXES - Page source (to be decided) - cookies - history (io-slave) +- file protocol view - -- cgit v1.2.1 From 5128265f02e16f40dd3df044eb86c147b76513a4 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 1 Apr 2009 23:42:57 +0200 Subject: 99% fixed target _blank issue.. --- src/webview.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/webview.cpp b/src/webview.cpp index 1057a5ef..4cb146f6 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -97,7 +97,6 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r if(m_keyboardModifiers & Qt::ControlModifier || m_pressedButtons == Qt::MidButton) { - kWarning() << "ControlModifiers clicked.."; webView = Application::instance()->newWebView(); webView->setFocus(); webView->load(request); @@ -113,11 +112,14 @@ bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &r } else { - kWarning() << "NO Main Frame, creating a new WebView.."; - webView = Application::instance()->newWebView(); - webView->setFocus(); - webView->load(request); - return false; + // if frame doesn't exists (perhaps) we are pointing to a blank target.. + if(!frame) + { + webView = Application::instance()->newWebView(); + webView->setFocus(); + webView->load(request); + return false; + } } break; -- cgit v1.2.1 From fb612bbc722ef83c65c63961723f10969f9a6cee Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Wed, 1 Apr 2009 12:48:03 +0200 Subject: Importing clones PART 1 I apologies for this "strange" way of importing code. But we have 3 (or 4) different ideas about UIs.. and I have to decide one. So, best way I found is importing manually changes. I'll write something about that soon. We basically need to better learn git cooperation (I'm first). Anyway, thank you a lot for your time and your ideas. I really apprecciate your efforts ;) --- TODO | 1 - src/mainwindow.cpp | 51 +++++++++++++++++++++++++++++++++------------------ src/mainwindow.h | 9 ++++++--- src/rekonqui.rc | 12 ++++++++++-- 4 files changed, 49 insertions(+), 24 deletions(-) diff --git a/TODO b/TODO index 49ee0a58..ca5d11fc 100644 --- a/TODO +++ b/TODO @@ -24,4 +24,3 @@ LONG TERM FIXES - cookies - history (io-slave) - file protocol view -- diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2a5f9295..92040bfe 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -65,12 +65,14 @@ MainWindow::MainWindow() : KXmlGuiWindow() , m_view(new MainView(this)) , m_bookmarksProvider(new BookmarksProvider(this)) + , m_findBar(new FindBar(this)) + , m_searchBar(new SearchBar(this)) { // accept dnd setAcceptDrops(true); // updating rekonq configuration - slotUpdateConf(); + slotUpdateConfiguration(); // creating a centralWidget containing m_view and the hidden findbar QWidget *centralWidget = new QWidget; @@ -78,8 +80,7 @@ MainWindow::MainWindow() layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(m_view); - // Find Bar - m_findBar = new FindBar(this); + // Adding Find Bar connect(m_findBar, SIGNAL(searchString(const QString &)), this, SLOT(slotFind(const QString &))); layout->addWidget(m_findBar); @@ -112,6 +113,9 @@ MainWindow::MainWindow() // add a status bar statusBar()->show(); + // setting up toolbars: this has to be done BEFORE setupGUI!! + setupToolBars(); + // ----- BOOKMARKS MENU: this has to be done BEFORE setupGUI!! KAction *a = new KActionMenu(i18n("B&ookmarks"), this); actionCollection()->addAction(QLatin1String("bookmarks"), a); @@ -125,26 +129,14 @@ MainWindow::MainWindow() // toolbar position, icon size, etc. setupGUI(); - // setup history menu + // setup history menu: this has to be done AFTER setupGUI!! setupHistoryMenu(); // setup Tab Bar setupTabBar(); - // setting up custom widgets.. - KToolBar *navigationBar = toolBar("mainToolBar"); - navigationBar->addWidget(m_view->lineEditStack()); - - KToolBar *bmToolbar = toolBar("bookmarksToolBar"); - m_bookmarksProvider->provideBmToolbar(bmToolbar); - // setting up toolbars to NOT have context menu enabled setContextMenuPolicy(Qt::DefaultContextMenu); - - // search bar - m_searchBar = new SearchBar(this); - connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); - navigationBar->addWidget(m_searchBar); } @@ -162,6 +154,29 @@ QSize MainWindow::sizeHint() const } +void MainWindow::setupToolBars() +{ + KAction *a; + + // location bar + a = new KAction(i18n("Location Bar"), this); + a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_L, Qt::Key_F6)); + a->setDefaultWidget(m_view->lineEditStack()); + actionCollection()->addAction(QLatin1String("url_bar"), a); + + // search bar + a = new KAction(i18n("Search Bar"), this); + a->setShortcut(KShortcut(Qt::CTRL + Qt::Key_K)); + a->setDefaultWidget(m_searchBar); + connect(m_searchBar, SIGNAL(search(const KUrl&)), this, SLOT(loadUrl(const KUrl&))); + actionCollection()->addAction(QLatin1String("search_bar"), a); + + // bookmarks bar + KToolBar *bmToolbar = toolBar("bookmarksToolBar"); + m_bookmarksProvider->provideBmToolbar(bmToolbar); +} + + void MainWindow::setupActions() { KAction *a; @@ -298,7 +313,7 @@ void MainWindow::setupHistoryMenu() } -void MainWindow::slotUpdateConf() +void MainWindow::slotUpdateConfiguration() { // ============== General ================== m_homePage = ReKonfig::homePage(); @@ -334,7 +349,7 @@ void MainWindow::slotUpdateConf() void MainWindow::slotUpdateBrowser() { - slotUpdateConf(); + slotUpdateConfiguration(); mainView()->reloadAllTabs(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index c9bec75e..c12f8fce 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -64,6 +64,7 @@ private: void setupActions(); void setupHistoryMenu(); void setupTabBar(); + void setupToolBars(); public slots: void slotHome(); @@ -71,7 +72,7 @@ public slots: void slotUpdateBrowser(); private slots: - void slotUpdateConf(); + void slotUpdateConfiguration(); void slotLoadProgress(int); void slotUpdateStatusbar(const QString &string); void slotUpdateActions(); @@ -114,20 +115,22 @@ private slots: void slotPreferences(); private: - SearchBar *m_searchBar; - FindBar *m_findBar; KMenu *m_historyBackMenu; KMenu *m_windowMenu; + KAction *m_stopReloadAction; KAction *m_stopAction; KAction *m_reloadAction; KAction *m_historyBackAction; KAction *m_historyForwardAction; + QString m_lastSearch; QString m_homePage; MainView *m_view; BookmarksProvider *m_bookmarksProvider; + FindBar *m_findBar; + SearchBar *m_searchBar; }; #endif // MAINWINDOW_H diff --git a/src/rekonqui.rc b/src/rekonqui.rc index babf2c62..bc4f9c37 100644 --- a/src/rekonqui.rc +++ b/src/rekonqui.rc @@ -1,6 +1,6 @@ - + @@ -68,13 +68,21 @@ -Main Toolbar + +Main Toolbar + + +Location Toolbar + + + + - + Location Toolbar -