mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
parent
d6625c60fb
commit
a059c005ff
@ -17,6 +17,7 @@
|
|||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "qzsettings.h"
|
#include "qzsettings.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#include "webview.h"
|
||||||
|
|
||||||
QzSettings::QzSettings()
|
QzSettings::QzSettings()
|
||||||
{
|
{
|
||||||
@ -44,7 +45,7 @@ void QzSettings::loadSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup("Web-Browser-Settings");
|
settings.beginGroup("Web-Browser-Settings");
|
||||||
defaultZoom = settings.value("DefaultZoom", 100).toInt();
|
defaultZoomLevel = settings.value("DefaultZoomLevel", WebView::zoomLevels().indexOf(100)).toInt();
|
||||||
loadTabsOnActivation = settings.value("LoadTabsOnActivation", true).toBool();
|
loadTabsOnActivation = settings.value("LoadTabsOnActivation", true).toBool();
|
||||||
autoOpenProtocols = settings.value("AutomaticallyOpenProtocols", QStringList()).toStringList();
|
autoOpenProtocols = settings.value("AutomaticallyOpenProtocols", QStringList()).toStringList();
|
||||||
blockedProtocols = settings.value("BlockOpeningProtocols", QStringList()).toStringList();
|
blockedProtocols = settings.value("BlockOpeningProtocols", QStringList()).toStringList();
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
bool searchWithDefaultEngine;
|
bool searchWithDefaultEngine;
|
||||||
|
|
||||||
// Web-Browser-Settings
|
// Web-Browser-Settings
|
||||||
int defaultZoom;
|
int defaultZoomLevel;
|
||||||
bool loadTabsOnActivation;
|
bool loadTabsOnActivation;
|
||||||
bool allowJsGeometryChange;
|
bool allowJsGeometryChange;
|
||||||
bool allowJsHideMenuBar;
|
bool allowJsHideMenuBar;
|
||||||
|
@ -287,10 +287,14 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
|
|||||||
ui->animateScrolling->setChecked(settings.value("AnimateScrolling", true).toBool());
|
ui->animateScrolling->setChecked(settings.value("AnimateScrolling", true).toBool());
|
||||||
ui->printEBackground->setChecked(settings.value("PrintElementBackground", true).toBool());
|
ui->printEBackground->setChecked(settings.value("PrintElementBackground", true).toBool());
|
||||||
ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt());
|
ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt());
|
||||||
ui->defaultZoom->setValue(settings.value("DefaultZoom", 100).toInt());
|
|
||||||
ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool());
|
ui->xssAuditing->setChecked(settings.value("XSSAuditing", false).toBool());
|
||||||
ui->formsUndoRedo->setChecked(settings.value("enableFormsUndoRedo", false).toBool());
|
ui->formsUndoRedo->setChecked(settings.value("enableFormsUndoRedo", false).toBool());
|
||||||
|
|
||||||
|
foreach (int level, WebView::zoomLevels()) {
|
||||||
|
ui->defaultZoomLevel->addItem(QString("%1%").arg(level));
|
||||||
|
}
|
||||||
|
ui->defaultZoomLevel->setCurrentIndex(settings.value("DefaultZoomLevel", WebView::zoomLevels().indexOf(100)).toInt());
|
||||||
|
|
||||||
//Cache
|
//Cache
|
||||||
ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt());
|
ui->pagesInCache->setValue(settings.value("maximumCachedPages", 3).toInt());
|
||||||
connect(ui->pagesInCache, SIGNAL(valueChanged(int)), this, SLOT(pageCacheValueChanged(int)));
|
connect(ui->pagesInCache, SIGNAL(valueChanged(int)), this, SLOT(pageCacheValueChanged(int)));
|
||||||
@ -978,7 +982,7 @@ void Preferences::saveSettings()
|
|||||||
settings.setValue("DoNotTrack", ui->doNotTrack->isChecked());
|
settings.setValue("DoNotTrack", ui->doNotTrack->isChecked());
|
||||||
settings.setValue("CheckUpdates", ui->checkUpdates->isChecked());
|
settings.setValue("CheckUpdates", ui->checkUpdates->isChecked());
|
||||||
settings.setValue("LoadTabsOnActivation", ui->dontLoadTabsUntilSelected->isChecked());
|
settings.setValue("LoadTabsOnActivation", ui->dontLoadTabsUntilSelected->isChecked());
|
||||||
settings.setValue("DefaultZoom", ui->defaultZoom->value());
|
settings.setValue("DefaultZoomLevel", ui->defaultZoomLevel->currentIndex());
|
||||||
settings.setValue("XSSAuditing", ui->xssAuditing->isChecked());
|
settings.setValue("XSSAuditing", ui->xssAuditing->isChecked());
|
||||||
settings.setValue("enableFormsUndoRedo", ui->formsUndoRedo->isChecked());
|
settings.setValue("enableFormsUndoRedo", ui->formsUndoRedo->isChecked());
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
@ -1219,20 +1219,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSpinBox" name="defaultZoom">
|
<widget class="QComboBox" name="defaultZoomLevel"/>
|
||||||
<property name="suffix">
|
|
||||||
<string notr="true"> %</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>30</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>300</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>100</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_12">
|
<spacer name="horizontalSpacer_12">
|
||||||
@ -2777,7 +2764,6 @@
|
|||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
<tabstop>allowPlugins</tabstop>
|
<tabstop>allowPlugins</tabstop>
|
||||||
<tabstop>wheelScroll</tabstop>
|
<tabstop>wheelScroll</tabstop>
|
||||||
<tabstop>defaultZoom</tabstop>
|
|
||||||
<tabstop>fontStandard</tabstop>
|
<tabstop>fontStandard</tabstop>
|
||||||
<tabstop>fontFixed</tabstop>
|
<tabstop>fontFixed</tabstop>
|
||||||
<tabstop>fontSerif</tabstop>
|
<tabstop>fontSerif</tabstop>
|
||||||
|
@ -53,7 +53,6 @@
|
|||||||
|
|
||||||
WebView::WebView(QWidget* parent)
|
WebView::WebView(QWidget* parent)
|
||||||
: QWebView(parent)
|
: QWebView(parent)
|
||||||
, m_currentZoom(100)
|
|
||||||
, m_isLoading(false)
|
, m_isLoading(false)
|
||||||
, m_progress(0)
|
, m_progress(0)
|
||||||
, m_clickedFrame(0)
|
, m_clickedFrame(0)
|
||||||
@ -72,8 +71,8 @@ WebView::WebView(QWidget* parent)
|
|||||||
connect(this, SIGNAL(iconChanged()), this, SLOT(slotIconChanged()));
|
connect(this, SIGNAL(iconChanged()), this, SLOT(slotIconChanged()));
|
||||||
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(slotUrlChanged(QUrl)));
|
connect(this, SIGNAL(urlChanged(QUrl)), this, SLOT(slotUrlChanged(QUrl)));
|
||||||
|
|
||||||
// Zoom levels same as in firefox
|
m_zoomLevels = zoomLevels();
|
||||||
m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300;
|
m_currentZoomLevel = m_zoomLevels.indexOf(100);
|
||||||
|
|
||||||
#if QTWEBKIT_TO_2_3
|
#if QTWEBKIT_TO_2_3
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
@ -158,10 +157,12 @@ void WebView::setPage(QWebPage* page)
|
|||||||
QWebView::setPage(page);
|
QWebView::setPage(page);
|
||||||
m_page = qobject_cast<WebPage*>(page);
|
m_page = qobject_cast<WebPage*>(page);
|
||||||
|
|
||||||
setZoom(qzSettings->defaultZoom);
|
|
||||||
connect(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)), this, SLOT(frameStateChanged()));
|
connect(m_page, SIGNAL(saveFrameStateRequested(QWebFrame*,QWebHistoryItem*)), this, SLOT(frameStateChanged()));
|
||||||
connect(m_page, SIGNAL(privacyChanged(bool)), this, SIGNAL(privacyChanged(bool)));
|
connect(m_page, SIGNAL(privacyChanged(bool)), this, SIGNAL(privacyChanged(bool)));
|
||||||
|
|
||||||
|
// Set default zoom level
|
||||||
|
zoomReset();
|
||||||
|
|
||||||
mApp->plugins()->emitWebPageCreated(m_page);
|
mApp->plugins()->emitWebPageCreated(m_page);
|
||||||
|
|
||||||
// Set white background by default.
|
// Set white background by default.
|
||||||
@ -232,6 +233,17 @@ QWebElement WebView::activeElement() const
|
|||||||
return page()->mainFrame()->hitTestContent(activeRect.center()).element();
|
return page()->mainFrame()->hitTestContent(activeRect.center()).element();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int WebView::zoomLevel() const
|
||||||
|
{
|
||||||
|
return m_currentZoomLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebView::setZoomLevel(int level)
|
||||||
|
{
|
||||||
|
m_currentZoomLevel = level;
|
||||||
|
applyZoom();
|
||||||
|
}
|
||||||
|
|
||||||
bool WebView::onBeforeUnload()
|
bool WebView::onBeforeUnload()
|
||||||
{
|
{
|
||||||
const QString res = page()->mainFrame()->evaluateJavaScript("window.onbeforeunload(new Event(\"beforeunload\"))").toString();
|
const QString res = page()->mainFrame()->evaluateJavaScript("window.onbeforeunload(new Event(\"beforeunload\"))").toString();
|
||||||
@ -243,12 +255,14 @@ bool WebView::onBeforeUnload()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
bool WebView::isUrlValid(const QUrl &url)
|
bool WebView::isUrlValid(const QUrl &url)
|
||||||
{
|
{
|
||||||
// Valid url must have scheme and actually contains something (therefore scheme:// is invalid)
|
// Valid url must have scheme and actually contains something (therefore scheme:// is invalid)
|
||||||
return url.isValid() && !url.scheme().isEmpty() && (!url.host().isEmpty() || !url.path().isEmpty() || url.hasQuery());
|
return url.isValid() && !url.scheme().isEmpty() && (!url.host().isEmpty() || !url.path().isEmpty() || url.hasQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
QUrl WebView::guessUrlFromString(const QString &string)
|
QUrl WebView::guessUrlFromString(const QString &string)
|
||||||
{
|
{
|
||||||
QString trimmedString = string.trimmed();
|
QString trimmedString = string.trimmed();
|
||||||
@ -284,6 +298,14 @@ QUrl WebView::guessUrlFromString(const QString &string)
|
|||||||
return QUrl();
|
return QUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QList<int> WebView::zoomLevels()
|
||||||
|
{
|
||||||
|
return QList<int>() << 30 << 40 << 50 << 67 << 80 << 90 << 100
|
||||||
|
<< 110 << 120 << 133 << 150 << 170 << 200
|
||||||
|
<< 220 << 233 << 250 << 270 << 285 << 300;
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::addNotification(QWidget* notif)
|
void WebView::addNotification(QWidget* notif)
|
||||||
{
|
{
|
||||||
emit showNotification(notif);
|
emit showNotification(notif);
|
||||||
@ -291,36 +313,34 @@ void WebView::addNotification(QWidget* notif)
|
|||||||
|
|
||||||
void WebView::applyZoom()
|
void WebView::applyZoom()
|
||||||
{
|
{
|
||||||
setZoomFactor(qreal(m_currentZoom) / 100.0);
|
setZoomFactor(qreal(m_zoomLevels.at(m_currentZoomLevel)) / 100.0);
|
||||||
|
|
||||||
|
emit zoomLevelChanged(m_currentZoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::zoomIn()
|
void WebView::zoomIn()
|
||||||
{
|
{
|
||||||
int i = m_zoomLevels.indexOf(m_currentZoom);
|
if (m_currentZoomLevel < m_zoomLevels.count() - 1) {
|
||||||
|
m_currentZoomLevel++;
|
||||||
if (i < m_zoomLevels.count() - 1) {
|
|
||||||
m_currentZoom = m_zoomLevels[i + 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
applyZoom();
|
applyZoom();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::zoomOut()
|
void WebView::zoomOut()
|
||||||
{
|
{
|
||||||
int i = m_zoomLevels.indexOf(m_currentZoom);
|
if (m_currentZoomLevel > 0) {
|
||||||
|
m_currentZoomLevel--;
|
||||||
if (i > 0) {
|
|
||||||
m_currentZoom = m_zoomLevels[i - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
applyZoom();
|
applyZoom();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::zoomReset()
|
void WebView::zoomReset()
|
||||||
{
|
{
|
||||||
m_currentZoom = 100;
|
if (m_currentZoomLevel != qzSettings->defaultZoomLevel) {
|
||||||
|
m_currentZoomLevel = qzSettings->defaultZoomLevel;
|
||||||
applyZoom();
|
applyZoom();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::editUndo()
|
void WebView::editUndo()
|
||||||
{
|
{
|
||||||
@ -1464,12 +1484,6 @@ void WebView::resizeEvent(QResizeEvent* event)
|
|||||||
emit viewportResized(page()->viewportSize());
|
emit viewportResized(page()->viewportSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::setZoom(int zoom)
|
|
||||||
{
|
|
||||||
m_currentZoom = zoom;
|
|
||||||
applyZoom();
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// This function was taken and modified from QTestBrowser to fix bug #33 with flightradar24.com
|
// This function was taken and modified from QTestBrowser to fix bug #33 with flightradar24.com
|
||||||
// You can find original source and copyright here:
|
// You can find original source and copyright here:
|
||||||
|
@ -42,7 +42,6 @@ public:
|
|||||||
void setPage(QWebPage* page);
|
void setPage(QWebPage* page);
|
||||||
|
|
||||||
void load(const LoadRequest &request);
|
void load(const LoadRequest &request);
|
||||||
|
|
||||||
bool loadingError() const;
|
bool loadingError() const;
|
||||||
bool isLoading() const;
|
bool isLoading() const;
|
||||||
|
|
||||||
@ -52,6 +51,10 @@ public:
|
|||||||
bool hasRss() const;
|
bool hasRss() const;
|
||||||
QWebElement activeElement() const;
|
QWebElement activeElement() const;
|
||||||
|
|
||||||
|
// Set zoom level (0 - 17)
|
||||||
|
int zoomLevel() const;
|
||||||
|
void setZoomLevel(int level);
|
||||||
|
|
||||||
// Executes window.onbeforeunload, returns true if view can be closed
|
// Executes window.onbeforeunload, returns true if view can be closed
|
||||||
bool onBeforeUnload();
|
bool onBeforeUnload();
|
||||||
|
|
||||||
@ -62,12 +65,14 @@ public:
|
|||||||
|
|
||||||
static bool isUrlValid(const QUrl &url);
|
static bool isUrlValid(const QUrl &url);
|
||||||
static QUrl guessUrlFromString(const QString &string);
|
static QUrl guessUrlFromString(const QString &string);
|
||||||
|
static QList<int> zoomLevels();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void viewportResized(QSize);
|
void viewportResized(QSize);
|
||||||
void showNotification(QWidget*);
|
void showNotification(QWidget*);
|
||||||
void privacyChanged(bool);
|
void privacyChanged(bool);
|
||||||
void rssChanged(bool);
|
void rssChanged(bool);
|
||||||
|
void zoomLevelChanged(int);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
@ -147,7 +152,6 @@ protected:
|
|||||||
void keyReleaseEvent(QKeyEvent* event);
|
void keyReleaseEvent(QKeyEvent* event);
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event);
|
||||||
|
|
||||||
void setZoom(int zoom);
|
|
||||||
void applyZoom();
|
void applyZoom();
|
||||||
QUrl lastUrl();
|
QUrl lastUrl();
|
||||||
|
|
||||||
@ -172,7 +176,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QList<int> m_zoomLevels;
|
QList<int> m_zoomLevels;
|
||||||
int m_currentZoom;
|
int m_currentZoomLevel;
|
||||||
|
|
||||||
QIcon m_siteIcon;
|
QIcon m_siteIcon;
|
||||||
QUrl m_siteIconUrl;
|
QUrl m_siteIconUrl;
|
||||||
|
@ -11,7 +11,8 @@ SOURCES += statusbariconsplugin.cpp \
|
|||||||
sbi_networkicondialog.cpp \
|
sbi_networkicondialog.cpp \
|
||||||
sbi_networkmanager.cpp \
|
sbi_networkmanager.cpp \
|
||||||
sbi_settingsdialog.cpp \
|
sbi_settingsdialog.cpp \
|
||||||
sbi_icon.cpp
|
sbi_icon.cpp \
|
||||||
|
sbi_zoomwidget.cpp
|
||||||
|
|
||||||
HEADERS += statusbariconsplugin.h \
|
HEADERS += statusbariconsplugin.h \
|
||||||
sbi_iconsmanager.h \
|
sbi_iconsmanager.h \
|
||||||
@ -23,7 +24,8 @@ HEADERS += statusbariconsplugin.h \
|
|||||||
sbi_networkicondialog.h \
|
sbi_networkicondialog.h \
|
||||||
sbi_networkmanager.h \
|
sbi_networkmanager.h \
|
||||||
sbi_settingsdialog.h \
|
sbi_settingsdialog.h \
|
||||||
sbi_icon.h
|
sbi_icon.h \
|
||||||
|
sbi_zoomwidget.h
|
||||||
|
|
||||||
RESOURCES += statusbaricons.qrc
|
RESOURCES += statusbaricons.qrc
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "sbi_iconsmanager.h"
|
#include "sbi_iconsmanager.h"
|
||||||
#include "sbi_imagesicon.h"
|
#include "sbi_imagesicon.h"
|
||||||
#include "sbi_javascripticon.h"
|
#include "sbi_javascripticon.h"
|
||||||
|
#include "sbi_zoomwidget.h"
|
||||||
#include "sbi_networkicon.h"
|
#include "sbi_networkicon.h"
|
||||||
#include "sbi_networkmanager.h"
|
#include "sbi_networkmanager.h"
|
||||||
#include "browserwindow.h"
|
#include "browserwindow.h"
|
||||||
@ -31,6 +32,7 @@ SBI_IconsManager::SBI_IconsManager(const QString &settingsPath, QObject* parent)
|
|||||||
, m_showImagesIcon(false)
|
, m_showImagesIcon(false)
|
||||||
, m_showJavaScriptIcon(false)
|
, m_showJavaScriptIcon(false)
|
||||||
, m_showNetworkIcon(false)
|
, m_showNetworkIcon(false)
|
||||||
|
, m_showZoomWidget(false)
|
||||||
, m_networkManager(0)
|
, m_networkManager(0)
|
||||||
{
|
{
|
||||||
loadSettings();
|
loadSettings();
|
||||||
@ -43,6 +45,7 @@ void SBI_IconsManager::loadSettings()
|
|||||||
m_showImagesIcon = settings.value("showImagesIcon", true).toBool();
|
m_showImagesIcon = settings.value("showImagesIcon", true).toBool();
|
||||||
m_showJavaScriptIcon = settings.value("showJavaScriptIcon", true).toBool();
|
m_showJavaScriptIcon = settings.value("showJavaScriptIcon", true).toBool();
|
||||||
m_showNetworkIcon = settings.value("showNetworkIcon", true).toBool();
|
m_showNetworkIcon = settings.value("showNetworkIcon", true).toBool();
|
||||||
|
m_showZoomWidget = settings.value("showZoomWidget", true).toBool();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +56,7 @@ bool SBI_IconsManager::showImagesIcon() const
|
|||||||
|
|
||||||
void SBI_IconsManager::setShowImagesIcon(bool show)
|
void SBI_IconsManager::setShowImagesIcon(bool show)
|
||||||
{
|
{
|
||||||
QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat);
|
QSettings settings(m_settingsPath + QL1S("extensions.ini"), QSettings::IniFormat);
|
||||||
settings.setValue("StatusBarIcons/showImagesIcon", show);
|
settings.setValue("StatusBarIcons/showImagesIcon", show);
|
||||||
|
|
||||||
m_showImagesIcon = show;
|
m_showImagesIcon = show;
|
||||||
@ -66,7 +69,7 @@ bool SBI_IconsManager::showJavaScriptIcon() const
|
|||||||
|
|
||||||
void SBI_IconsManager::setShowJavaScriptIcon(bool show)
|
void SBI_IconsManager::setShowJavaScriptIcon(bool show)
|
||||||
{
|
{
|
||||||
QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat);
|
QSettings settings(m_settingsPath + QL1S("extensions.ini"), QSettings::IniFormat);
|
||||||
settings.setValue("StatusBarIcons/showJavaScriptIcon", show);
|
settings.setValue("StatusBarIcons/showJavaScriptIcon", show);
|
||||||
|
|
||||||
m_showJavaScriptIcon = show;
|
m_showJavaScriptIcon = show;
|
||||||
@ -79,12 +82,25 @@ bool SBI_IconsManager::showNetworkIcon() const
|
|||||||
|
|
||||||
void SBI_IconsManager::setShowNetworkIcon(bool show)
|
void SBI_IconsManager::setShowNetworkIcon(bool show)
|
||||||
{
|
{
|
||||||
QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat);
|
QSettings settings(m_settingsPath + QL1S("extensions.ini"), QSettings::IniFormat);
|
||||||
settings.setValue("StatusBarIcons/showNetworkIcon", show);
|
settings.setValue("StatusBarIcons/showNetworkIcon", show);
|
||||||
|
|
||||||
m_showNetworkIcon = show;
|
m_showNetworkIcon = show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SBI_IconsManager::showZoomWidget() const
|
||||||
|
{
|
||||||
|
return m_showZoomWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBI_IconsManager::setShowZoomWidget(bool show)
|
||||||
|
{
|
||||||
|
QSettings settings(m_settingsPath + QL1S("extensions.ini"), QSettings::IniFormat);
|
||||||
|
settings.setValue("StatusBarIcons/showZoomWidget", show);
|
||||||
|
|
||||||
|
m_showZoomWidget = show;
|
||||||
|
}
|
||||||
|
|
||||||
void SBI_IconsManager::reloadIcons()
|
void SBI_IconsManager::reloadIcons()
|
||||||
{
|
{
|
||||||
QHashIterator<BrowserWindow*, QWidgetList> it(m_windows);
|
QHashIterator<BrowserWindow*, QWidgetList> it(m_windows);
|
||||||
@ -129,6 +145,12 @@ void SBI_IconsManager::mainWindowCreated(BrowserWindow* window)
|
|||||||
window->statusBar()->addPermanentWidget(w);
|
window->statusBar()->addPermanentWidget(w);
|
||||||
m_windows[window].append(w);
|
m_windows[window].append(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_showZoomWidget) {
|
||||||
|
SBI_ZoomWidget* w = new SBI_ZoomWidget(window);
|
||||||
|
window->statusBar()->addPermanentWidget(w);
|
||||||
|
m_windows[window].append(w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SBI_IconsManager::mainWindowDeleted(BrowserWindow* window)
|
void SBI_IconsManager::mainWindowDeleted(BrowserWindow* window)
|
||||||
|
@ -42,6 +42,9 @@ public:
|
|||||||
bool showNetworkIcon() const;
|
bool showNetworkIcon() const;
|
||||||
void setShowNetworkIcon(bool show);
|
void setShowNetworkIcon(bool show);
|
||||||
|
|
||||||
|
bool showZoomWidget() const;
|
||||||
|
void setShowZoomWidget(bool show);
|
||||||
|
|
||||||
void reloadIcons();
|
void reloadIcons();
|
||||||
void destroyIcons();
|
void destroyIcons();
|
||||||
|
|
||||||
@ -56,6 +59,7 @@ private:
|
|||||||
bool m_showImagesIcon;
|
bool m_showImagesIcon;
|
||||||
bool m_showJavaScriptIcon;
|
bool m_showJavaScriptIcon;
|
||||||
bool m_showNetworkIcon;
|
bool m_showNetworkIcon;
|
||||||
|
bool m_showZoomWidget;
|
||||||
|
|
||||||
QHash<BrowserWindow*, QWidgetList> m_windows;
|
QHash<BrowserWindow*, QWidgetList> m_windows;
|
||||||
SBI_NetworkManager* m_networkManager;
|
SBI_NetworkManager* m_networkManager;
|
||||||
|
@ -29,6 +29,7 @@ SBI_SettingsDialog::SBI_SettingsDialog(SBI_IconsManager* manager, QWidget* paren
|
|||||||
ui->showImagesIcon->setChecked(m_manager->showImagesIcon());
|
ui->showImagesIcon->setChecked(m_manager->showImagesIcon());
|
||||||
ui->showJavaScriptIcon->setChecked(m_manager->showJavaScriptIcon());
|
ui->showJavaScriptIcon->setChecked(m_manager->showJavaScriptIcon());
|
||||||
ui->showNetworkIcon->setChecked(m_manager->showNetworkIcon());
|
ui->showNetworkIcon->setChecked(m_manager->showNetworkIcon());
|
||||||
|
ui->showZoomWidget->setChecked(m_manager->showZoomWidget());
|
||||||
|
|
||||||
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
|
||||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||||
@ -39,6 +40,7 @@ void SBI_SettingsDialog::saveSettings()
|
|||||||
m_manager->setShowImagesIcon(ui->showImagesIcon->isChecked());
|
m_manager->setShowImagesIcon(ui->showImagesIcon->isChecked());
|
||||||
m_manager->setShowJavaScriptIcon(ui->showJavaScriptIcon->isChecked());
|
m_manager->setShowJavaScriptIcon(ui->showJavaScriptIcon->isChecked());
|
||||||
m_manager->setShowNetworkIcon(ui->showNetworkIcon->isChecked());
|
m_manager->setShowNetworkIcon(ui->showNetworkIcon->isChecked());
|
||||||
|
m_manager->setShowZoomWidget(ui->showZoomWidget->isChecked());
|
||||||
|
|
||||||
m_manager->reloadIcons();
|
m_manager->reloadIcons();
|
||||||
close();
|
close();
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>345</width>
|
<width>343</width>
|
||||||
<height>186</height>
|
<height>204</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -112,6 +112,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="showZoomWidget">
|
||||||
|
<property name="text">
|
||||||
|
<string>Zoom widget</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
59
src/plugins/StatusBarIcons/sbi_zoomwidget.cpp
Normal file
59
src/plugins/StatusBarIcons/sbi_zoomwidget.cpp
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* StatusBarIcons - Extra icons in statusbar for QupZilla
|
||||||
|
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#include "sbi_zoomwidget.h"
|
||||||
|
#include "tabbedwebview.h"
|
||||||
|
#include "browserwindow.h"
|
||||||
|
#include "tabwidget.h"
|
||||||
|
|
||||||
|
SBI_ZoomWidget::SBI_ZoomWidget(BrowserWindow* parent)
|
||||||
|
: QSlider(parent)
|
||||||
|
, m_window(parent)
|
||||||
|
{
|
||||||
|
setOrientation(Qt::Horizontal);
|
||||||
|
setFixedWidth(100);
|
||||||
|
setMaximumHeight(20);
|
||||||
|
|
||||||
|
setPageStep(2);
|
||||||
|
setSingleStep(1);
|
||||||
|
setRange(0, WebView::zoomLevels().count() - 1);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(valueChanged(int)), this, SLOT(valueChanged(int)));
|
||||||
|
connect(m_window->tabWidget(), SIGNAL(currentChanged(int)), this, SLOT(currentViewChanged()));
|
||||||
|
|
||||||
|
currentViewChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBI_ZoomWidget::valueChanged(int value)
|
||||||
|
{
|
||||||
|
TabbedWebView* view = m_window->weView();
|
||||||
|
|
||||||
|
if (view) {
|
||||||
|
view->setZoomLevel(value);
|
||||||
|
setToolTip(tr("Zoom: %1%").arg(view->zoomFactor() * 100));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SBI_ZoomWidget::currentViewChanged()
|
||||||
|
{
|
||||||
|
TabbedWebView* view = m_window->weView();
|
||||||
|
|
||||||
|
if (view) {
|
||||||
|
connect(view, SIGNAL(zoomLevelChanged(int)), this, SLOT(setValue(int)));
|
||||||
|
setValue(view->zoomLevel());
|
||||||
|
}
|
||||||
|
}
|
40
src/plugins/StatusBarIcons/sbi_zoomwidget.h
Normal file
40
src/plugins/StatusBarIcons/sbi_zoomwidget.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* ============================================================
|
||||||
|
* StatusBarIcons - Extra icons in statusbar for QupZilla
|
||||||
|
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
* ============================================================ */
|
||||||
|
#ifndef SBI_ZOOMWIDGET_H
|
||||||
|
#define SBI_ZOOMWIDGET_H
|
||||||
|
|
||||||
|
#include <QSlider>
|
||||||
|
|
||||||
|
class BrowserWindow;
|
||||||
|
|
||||||
|
class SBI_ZoomWidget : public QSlider
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SBI_ZoomWidget(BrowserWindow* parent = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void valueChanged(int value);
|
||||||
|
void currentViewChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
BrowserWindow* m_window;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SBI_ZOOMWIDGET_H
|
@ -34,8 +34,8 @@ PluginSpec StatusBarIconsPlugin::pluginSpec()
|
|||||||
PluginSpec spec;
|
PluginSpec spec;
|
||||||
spec.name = "StatusBar Icons";
|
spec.name = "StatusBar Icons";
|
||||||
spec.info = "Icons in statusbar providing various actions";
|
spec.info = "Icons in statusbar providing various actions";
|
||||||
spec.description = "Adds additional icons to statusbar";
|
spec.description = "Adds additional icons and zoom widget to statusbar";
|
||||||
spec.version = "0.1.6";
|
spec.version = "0.2.0";
|
||||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||||
spec.icon = QPixmap(":sbi/data/icon.png");
|
spec.icon = QPixmap(":sbi/data/icon.png");
|
||||||
spec.hasSettings = true;
|
spec.hasSettings = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user