diff --git a/CHANGELOG b/CHANGELOG index 9191eca60..bcf52939c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,8 @@ Version 1.5.0 * added possibility to remove EasyList from AdBlock * added inline domain completion to urlbar * added KWallet password backend plugin + * added Gnome-Keyring password backend plugin + * added StatusBar Icons plugin that adds extra icons to statusbar * proxy exceptions now supports wildcards (*, ?) * cancel upload when trying to upload non-readable files * GreaseMonkey: added support for GM_Settings diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index 8e5c856e9..fb2e119a6 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -351,10 +351,10 @@ void QupZilla::setupUi() m_ipLabel->setObjectName("statusbar-ip-label"); m_ipLabel->setToolTip(tr("IP Address of current page")); - statusBar()->insertPermanentWidget(0, m_progressBar); - statusBar()->insertPermanentWidget(1, m_ipLabel); - statusBar()->insertPermanentWidget(2, m_privateBrowsing); - statusBar()->insertPermanentWidget(3, m_adblockIcon); + statusBar()->addPermanentWidget(m_progressBar); + statusBar()->addPermanentWidget(m_ipLabel); + statusBar()->addPermanentWidget(m_privateBrowsing); + statusBar()->addPermanentWidget(m_adblockIcon); // Workaround for Oxygen tooltips not having transparent background QPalette pal = QToolTip::palette(); diff --git a/src/lib/webview/tabwidget.h b/src/lib/webview/tabwidget.h index 1868b767f..8df8d75a0 100644 --- a/src/lib/webview/tabwidget.h +++ b/src/lib/webview/tabwidget.h @@ -85,6 +85,9 @@ public: void showNavigationBar(QWidget* bar); + WebTab* weTab(); + WebTab* weTab(int index); + TabBar* getTabBar() const; ClosedTabsManager* closedTabsManager() const; QList allTabs(bool withPinned = true); @@ -138,9 +141,6 @@ private: void resizeEvent(QResizeEvent* e); - WebTab* weTab(); - WebTab* weTab(int index); - bool m_hideTabBarWithOneTab; bool m_dontQuitWithOneTab; bool m_closedInsteadOpened; diff --git a/src/plugins/GnomeKeyringPasswords/translations/empty.ts b/src/plugins/GnomeKeyringPasswords/translations/empty.ts index 39ac73c00..77342e627 100644 --- a/src/plugins/GnomeKeyringPasswords/translations/empty.ts +++ b/src/plugins/GnomeKeyringPasswords/translations/empty.ts @@ -4,7 +4,7 @@ GnomeKeyringPlugin - + Gnome Keyring diff --git a/src/plugins/StatusBarIcons/StatusBarIcons.pro b/src/plugins/StatusBarIcons/StatusBarIcons.pro new file mode 100644 index 000000000..b9a816424 --- /dev/null +++ b/src/plugins/StatusBarIcons/StatusBarIcons.pro @@ -0,0 +1,15 @@ +include(../../defines.pri) + +TARGET = $$qtLibraryTarget(StatusBarIcons) + +SOURCES += statusbariconsplugin.cpp \ + sbi_iconsmanager.cpp \ + sbi_imagesicon.cpp + +HEADERS += statusbariconsplugin.h \ + sbi_iconsmanager.h \ + sbi_imagesicon.h + +RESOURCES += statusbaricons.qrc + +include(../../plugins.pri) diff --git a/src/plugins/StatusBarIcons/data/icon.png b/src/plugins/StatusBarIcons/data/icon.png new file mode 100644 index 000000000..32d838532 Binary files /dev/null and b/src/plugins/StatusBarIcons/data/icon.png differ diff --git a/src/plugins/StatusBarIcons/data/images.png b/src/plugins/StatusBarIcons/data/images.png new file mode 100644 index 000000000..c7553602e Binary files /dev/null and b/src/plugins/StatusBarIcons/data/images.png differ diff --git a/src/plugins/StatusBarIcons/sbi_iconsmanager.cpp b/src/plugins/StatusBarIcons/sbi_iconsmanager.cpp new file mode 100644 index 000000000..70ced13fe --- /dev/null +++ b/src/plugins/StatusBarIcons/sbi_iconsmanager.cpp @@ -0,0 +1,99 @@ +/* ============================================================ +* StatusBarIcons - Extra icons in statusbar for QupZilla +* Copyright (C) 2013 David Rosca +* +* 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 . +* ============================================================ */ +#include "sbi_iconsmanager.h" +#include "sbi_imagesicon.h" +#include "qupzilla.h" + +#include +#include +#include + +SBI_IconsManager::SBI_IconsManager(const QString &settingsPath, QObject* parent) + : QObject(parent) + , m_settingsPath(settingsPath) + , m_showImagesIcon(false) + , m_showJavaScriptIcon(false) + , m_showNetworkIcon(false) +{ + loadSettings(); +} + +void SBI_IconsManager::loadSettings() +{ + QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat); + settings.beginGroup("StatusBarIcons"); + m_showImagesIcon = settings.value("showImagesIcon", true).toBool(); + m_showJavaScriptIcon = settings.value("showJavaScriptIcon", true).toBool(); + m_showNetworkIcon = settings.value("showNetworkIcon", true).toBool(); + settings.endGroup(); +} + +void SBI_IconsManager::reloadIcons() +{ + QHashIterator it(m_windows); + + while (it.hasNext()) { + it.next(); + mainWindowDeleted(it.key()); + mainWindowCreated(it.key()); + } +} + +void SBI_IconsManager::destroyIcons() +{ + QHashIterator it(m_windows); + + while (it.hasNext()) { + it.next(); + mainWindowDeleted(it.key()); + } +} + +void SBI_IconsManager::mainWindowCreated(QupZilla* window) +{ + typedef QWidget SBI_JavaScriptIcon; + typedef QWidget SBI_NetworkIcon; + + if (m_showImagesIcon) { + SBI_ImagesIcon* w = new SBI_ImagesIcon(window, m_settingsPath); + window->statusBar()->addPermanentWidget(w); + m_windows[window].append(w); + } + + if (m_showJavaScriptIcon) { + SBI_JavaScriptIcon* w = new SBI_JavaScriptIcon; + window->statusBar()->addPermanentWidget(w); + m_windows[window].append(w); + } + + if (m_showNetworkIcon) { + SBI_NetworkIcon* w = new SBI_NetworkIcon; + window->statusBar()->addPermanentWidget(w); + m_windows[window].append(w); + } +} + +void SBI_IconsManager::mainWindowDeleted(QupZilla* window) +{ + foreach (QWidget* w, m_windows[window]) { + window->statusBar()->removeWidget(w); + delete w; + } + + m_windows[window].clear(); +} diff --git a/src/plugins/StatusBarIcons/sbi_iconsmanager.h b/src/plugins/StatusBarIcons/sbi_iconsmanager.h new file mode 100644 index 000000000..364b0d989 --- /dev/null +++ b/src/plugins/StatusBarIcons/sbi_iconsmanager.h @@ -0,0 +1,52 @@ +/* ============================================================ +* StatusBarIcons - Extra icons in statusbar for QupZilla +* Copyright (C) 2013 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef SBI_ICONSMANAGER_H +#define SBI_ICONSMANAGER_H + +#include +#include + +class QupZilla; + +class SBI_IconsManager : public QObject +{ + Q_OBJECT +public: + explicit SBI_IconsManager(const QString &settingsPath, QObject* parent = 0); + + void loadSettings(); + + void reloadIcons(); + void destroyIcons(); + +signals: + +public slots: + void mainWindowCreated(QupZilla* window); + void mainWindowDeleted(QupZilla* window); + +private: + QString m_settingsPath; + bool m_showImagesIcon; + bool m_showJavaScriptIcon; + bool m_showNetworkIcon; + + QHash m_windows; +}; + +#endif // SBI_ICONSMANAGER_H diff --git a/src/plugins/StatusBarIcons/sbi_imagesicon.cpp b/src/plugins/StatusBarIcons/sbi_imagesicon.cpp new file mode 100644 index 000000000..6b5c23a34 --- /dev/null +++ b/src/plugins/StatusBarIcons/sbi_imagesicon.cpp @@ -0,0 +1,127 @@ +/* ============================================================ +* StatusBarIcons - Extra icons in statusbar for QupZilla +* Copyright (C) 2013 David Rosca +* +* 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 . +* ============================================================ */ +#include "sbi_imagesicon.h" +#include "mainapplication.h" +#include "qupzilla.h" +#include "tabwidget.h" +#include "tabbedwebview.h" +#include "webpage.h" + +#include +#include +#include +#include + +SBI_ImagesIcon::SBI_ImagesIcon(QupZilla* window, const QString &settingsPath) + : ClickableLabel(window) + , p_QupZilla(window) + , m_settingsFile(settingsPath + "extensions.ini") +{ + setCursor(Qt::PointingHandCursor); + setToolTip(tr("Modify images loading settings per-site and globally")); + + m_icon = QIcon::fromTheme("image-x-genericsss", QIcon(":sbi/data/images.png")); + setPixmap(m_icon.pixmap(16)); + + QSettings settings(m_settingsFile, QSettings::IniFormat); + settings.beginGroup("StatusBarIcons_Images"); + m_loadingImages = settings.value("LoadImages", true).toBool(); + settings.endGroup(); + + mApp->webSettings()->setAttribute(QWebSettings::AutoLoadImages, m_loadingImages); + + updateIcon(); + + connect(p_QupZilla->tabWidget(), SIGNAL(currentChanged(int)), this, SLOT(updateIcon())); + connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint))); +} + +void SBI_ImagesIcon::showMenu(const QPoint &point) +{ + QFont boldFont = font(); + boldFont.setBold(true); + + QMenu menu; + + menu.addAction(m_icon, tr("Current page settings"))->setFont(boldFont); + + if (currentPageSettings()->testAttribute(QWebSettings::AutoLoadImages)) { + menu.addAction(tr("Disable loading images (temporarily)"), this, SLOT(toggleLoadingImages())); + } + else { + menu.addAction(tr("Enable loading images (temporarily)"), this, SLOT(toggleLoadingImages())); + } + + menu.addSeparator(); + menu.addAction(m_icon, tr("Global settings"))->setFont(boldFont); + + QAction* act = menu.addAction(tr("Automatically load images")); + act->setCheckable(true); + act->setChecked(m_loadingImages); + connect(act, SIGNAL(toggled(bool)), this, SLOT(setGlobalLoadingImages(bool))); + + menu.exec(point); +} + +void SBI_ImagesIcon::toggleLoadingImages() +{ + bool current = currentPageSettings()->testAttribute(QWebSettings::AutoLoadImages); + currentPageSettings()->setAttribute(QWebSettings::AutoLoadImages, !current); + + // We should reload page on disabling images + if (current) { + p_QupZilla->tabWidget()->weTab()->reload(); + } + + updateIcon(); +} + +void SBI_ImagesIcon::setGlobalLoadingImages(bool enable) +{ + // Save it permanently + QSettings settings(m_settingsFile, QSettings::IniFormat); + settings.beginGroup("StatusBarIcons_Images"); + settings.setValue("LoadImages", enable); + settings.endGroup(); + + // Switch it in websettings + mApp->webSettings()->setAttribute(QWebSettings::AutoLoadImages, enable); + updateIcon(); + + // We should reload page on disabling images + if (!enable) { + p_QupZilla->tabWidget()->weTab()->reload(); + } +} + +QWebSettings* SBI_ImagesIcon::currentPageSettings() +{ + return p_QupZilla->tabWidget()->weTab()->view()->page()->settings(); +} + +void SBI_ImagesIcon::updateIcon() +{ + if (currentPageSettings()->testAttribute(QWebSettings::AutoLoadImages)) { + setGraphicsEffect(0); + } + else { + QGraphicsColorizeEffect* effect = new QGraphicsColorizeEffect(this); + effect->setColor(Qt::gray); + setGraphicsEffect(effect); + } +} diff --git a/src/plugins/StatusBarIcons/sbi_imagesicon.h b/src/plugins/StatusBarIcons/sbi_imagesicon.h new file mode 100644 index 000000000..24dd6be0f --- /dev/null +++ b/src/plugins/StatusBarIcons/sbi_imagesicon.h @@ -0,0 +1,53 @@ +/* ============================================================ +* StatusBarIcons - Extra icons in statusbar for QupZilla +* Copyright (C) 2013 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef SBI_IMAGESICON_H +#define SBI_IMAGESICON_H + +#include + +#include "clickablelabel.h" + +class QWebSettings; + +class QupZilla; + +class SBI_ImagesIcon : public ClickableLabel +{ + Q_OBJECT + +public: + explicit SBI_ImagesIcon(QupZilla* window, const QString &settingsPath); + +private slots: + void showMenu(const QPoint &point); + void updateIcon(); + + void toggleLoadingImages(); + void setGlobalLoadingImages(bool enable); + +private: + QWebSettings* currentPageSettings(); + + QupZilla* p_QupZilla; + QString m_settingsFile; + + QIcon m_icon; + bool m_loadingImages; +}; + +#endif // SBI_IMAGESICON_H diff --git a/src/plugins/StatusBarIcons/statusbaricons.qrc b/src/plugins/StatusBarIcons/statusbaricons.qrc new file mode 100644 index 000000000..1ba7940a3 --- /dev/null +++ b/src/plugins/StatusBarIcons/statusbaricons.qrc @@ -0,0 +1,6 @@ + + + data/icon.png + data/images.png + + diff --git a/src/plugins/StatusBarIcons/statusbariconsplugin.cpp b/src/plugins/StatusBarIcons/statusbariconsplugin.cpp new file mode 100644 index 000000000..d7dfcd64a --- /dev/null +++ b/src/plugins/StatusBarIcons/statusbariconsplugin.cpp @@ -0,0 +1,84 @@ +/* ============================================================ +* StatusBarIcons - Extra icons in statusbar for QupZilla +* Copyright (C) 2013 David Rosca +* +* 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 . +* ============================================================ */ +#include "statusbariconsplugin.h" +#include "sbi_iconsmanager.h" +#include "pluginproxy.h" +#include "qupzilla.h" + +#include + +StatusBarIconsPlugin::StatusBarIconsPlugin() + : QObject() + , m_manager(0) +{ +} + +PluginSpec StatusBarIconsPlugin::pluginSpec() +{ + PluginSpec spec; + spec.name = "StatusBar Icons"; + spec.info = "Icons in statusbar providing various actions"; + spec.description = "Adds additional icons to statusbar"; + spec.version = "0.1.0"; + spec.author = "David Rosca "; + spec.icon = QPixmap(":sbi/data/icon.png"); + spec.hasSettings = false; + + return spec; +} + +void StatusBarIconsPlugin::init(InitState state, const QString &settingsPath) +{ + m_manager = new SBI_IconsManager(settingsPath); + + connect(mApp->plugins(), SIGNAL(mainWindowCreated(QupZilla*)), m_manager, SLOT(mainWindowCreated(QupZilla*))); + connect(mApp->plugins(), SIGNAL(mainWindowDeleted(QupZilla*)), m_manager, SLOT(mainWindowDeleted(QupZilla*))); + + // Make sure icons are added also to already created windows + if (state == LateInitState) { + foreach (QupZilla* window, mApp->mainWindows()) { + m_manager->mainWindowCreated(window); + } + } +} + +void StatusBarIconsPlugin::unload() +{ + // Make sure icons are properly removed when unloading plugin (but not when closing app) + if (!mApp->isClosing()) { + foreach (QupZilla* window, mApp->mainWindows()) { + m_manager->mainWindowDeleted(window); + } + + delete m_manager; + } +} + +bool StatusBarIconsPlugin::testPlugin() +{ + return (QupZilla::VERSION == QLatin1String("1.5.0")); +} + +void StatusBarIconsPlugin::showSettings(QWidget* parent) +{ + Q_UNUSED(parent) +} + +#if QT_VERSION < 0x050000 +Q_EXPORT_PLUGIN2(StatusBarIcons, StatusBarIconsPlugin) +#endif diff --git a/src/plugins/StatusBarIcons/statusbariconsplugin.h b/src/plugins/StatusBarIcons/statusbariconsplugin.h new file mode 100644 index 000000000..45deb1b7f --- /dev/null +++ b/src/plugins/StatusBarIcons/statusbariconsplugin.h @@ -0,0 +1,49 @@ +/* ============================================================ +* StatusBarIcons - Extra icons in statusbar for QupZilla +* Copyright (C) 2013 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef STATUSBARICONSPLUGIN_H +#define STATUSBARICONSPLUGIN_H + +#include "plugininterface.h" + +class SBI_IconsManager; + +class StatusBarIconsPlugin : public QObject, public PluginInterface +{ + Q_OBJECT + Q_INTERFACES(PluginInterface) + +#if QT_VERSION >= 0x050000 + Q_PLUGIN_METADATA(IID "QupZilla.Browser.plugin.StatusBarIcons") +#endif + +public: + explicit StatusBarIconsPlugin(); + PluginSpec pluginSpec(); + + void init(InitState state, const QString &settingsPath); + void unload(); + bool testPlugin(); + + void showSettings(QWidget* parent = 0); + +private: + SBI_IconsManager* m_manager; + +}; + +#endif // STATUSBARICONSPLUGIN_H diff --git a/src/plugins/StatusBarIcons/translations/empty.ts b/src/plugins/StatusBarIcons/translations/empty.ts new file mode 100644 index 000000000..6f430b8eb --- /dev/null +++ b/src/plugins/StatusBarIcons/translations/empty.ts @@ -0,0 +1,37 @@ + + + + + SBI_ImagesIcon + + + Modify images loading settings per-site and globally + + + + + Current page settings + + + + + Disable loading images (temporarily) + + + + + Enable loading images (temporarily) + + + + + Global settings + + + + + Automatically load images + + + + diff --git a/src/plugins/TestPlugin/translations/empty.ts b/src/plugins/TestPlugin/translations/empty.ts index 087f269b1..8c29987bf 100644 --- a/src/plugins/TestPlugin/translations/empty.ts +++ b/src/plugins/TestPlugin/translations/empty.ts @@ -4,27 +4,27 @@ TestPlugin - + Close - + Example Plugin Settings - + My first plugin action - + Hello - + First plugin action works :-)