1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

[StatusBarIcons] Add settings dialog to disable/enable icons.

This commit is contained in:
nowrep 2013-05-29 23:59:56 +02:00
parent aa18827a49
commit 06e81bb557
8 changed files with 307 additions and 6 deletions

View File

@ -10,7 +10,8 @@ SOURCES += statusbariconsplugin.cpp \
sbi_networkproxy.cpp \
sbi_proxywidget.cpp \
sbi_networkicondialog.cpp \
sbi_networkmanager.cpp
sbi_networkmanager.cpp \
sbi_settingsdialog.cpp
HEADERS += statusbariconsplugin.h \
sbi_iconsmanager.h \
@ -20,7 +21,8 @@ HEADERS += statusbariconsplugin.h \
sbi_networkproxy.h \
sbi_proxywidget.h \
sbi_networkicondialog.h \
sbi_networkmanager.h
sbi_networkmanager.h \
sbi_settingsdialog.h
RESOURCES += statusbaricons.qrc
@ -28,4 +30,5 @@ include(../../plugins.pri)
FORMS += \
sbi_proxywidget.ui \
sbi_networkicondialog.ui
sbi_networkicondialog.ui \
sbi_settingsdialog.ui

View File

@ -47,6 +47,45 @@ void SBI_IconsManager::loadSettings()
settings.endGroup();
}
bool SBI_IconsManager::showImagesIcon() const
{
return m_showImagesIcon;
}
void SBI_IconsManager::setShowImagesIcon(bool show)
{
QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat);
settings.setValue("StatusBarIcons/showImagesIcon", show);
m_showImagesIcon = show;
}
bool SBI_IconsManager::showJavaScriptIcon() const
{
return m_showJavaScriptIcon;
}
void SBI_IconsManager::setShowJavaScriptIcon(bool show)
{
QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat);
settings.setValue("StatusBarIcons/showJavaScriptIcon", show);
m_showJavaScriptIcon = show;
}
bool SBI_IconsManager::showNetworkIcon() const
{
return m_showNetworkIcon;
}
void SBI_IconsManager::setShowNetworkIcon(bool show)
{
QSettings settings(m_settingsPath + "extensions.ini", QSettings::IniFormat);
settings.setValue("StatusBarIcons/showNetworkIcon", show);
m_showNetworkIcon = show;
}
void SBI_IconsManager::reloadIcons()
{
QHashIterator<QupZilla*, QWidgetList> it(m_windows);
@ -102,3 +141,8 @@ void SBI_IconsManager::mainWindowDeleted(QupZilla* window)
m_windows[window].clear();
}
SBI_IconsManager::~SBI_IconsManager()
{
delete m_networkManager;
}

View File

@ -29,9 +29,19 @@ class SBI_IconsManager : public QObject
Q_OBJECT
public:
explicit SBI_IconsManager(const QString &settingsPath, QObject* parent = 0);
~SBI_IconsManager();
void loadSettings();
bool showImagesIcon() const;
void setShowImagesIcon(bool show);
bool showJavaScriptIcon() const;
void setShowJavaScriptIcon(bool show);
bool showNetworkIcon() const;
void setShowNetworkIcon(bool show);
void reloadIcons();
void destroyIcons();

View File

@ -66,7 +66,7 @@ void SBI_NetworkIconDialog::addProxy()
void SBI_NetworkIconDialog::removeProxy()
{
QMessageBox::StandardButton button = QMessageBox::warning(this, tr("Remove current proxy"), tr("Are you sure to remove current proxy?"),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
if (button != QMessageBox::Yes) {
return;

View File

@ -0,0 +1,50 @@
/* ============================================================
* StatusBarIcons - Extra icons in statusbar for QupZilla
* Copyright (C) 2013 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_settingsdialog.h"
#include "ui_sbi_settingsdialog.h"
#include "sbi_iconsmanager.h"
SBI_SettingsDialog::SBI_SettingsDialog(SBI_IconsManager* manager, QWidget* parent)
: QDialog(parent)
, ui(new Ui::SBI_SettingsDialog)
, m_manager(manager)
{
ui->setupUi(this);
ui->showImagesIcon->setChecked(m_manager->showImagesIcon());
ui->showJavaScriptIcon->setChecked(m_manager->showJavaScriptIcon());
ui->showNetworkIcon->setChecked(m_manager->showNetworkIcon());
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveSettings()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
}
void SBI_SettingsDialog::saveSettings()
{
m_manager->setShowImagesIcon(ui->showImagesIcon->isChecked());
m_manager->setShowJavaScriptIcon(ui->showJavaScriptIcon->isChecked());
m_manager->setShowNetworkIcon(ui->showNetworkIcon->isChecked());
m_manager->reloadIcons();
close();
}
SBI_SettingsDialog::~SBI_SettingsDialog()
{
delete ui;
}

View File

@ -0,0 +1,47 @@
/* ============================================================
* StatusBarIcons - Extra icons in statusbar for QupZilla
* Copyright (C) 2013 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_SETTINGSDIALOG_H
#define SBI_SETTINGSDIALOG_H
#include <QDialog>
namespace Ui
{
class SBI_SettingsDialog;
}
class SBI_IconsManager;
class SBI_SettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit SBI_SettingsDialog(SBI_IconsManager* manager, QWidget* parent = 0);
~SBI_SettingsDialog();
private slots:
void saveSettings();
private:
Ui::SBI_SettingsDialog* ui;
SBI_IconsManager* m_manager;
};
#endif // SBI_SETTINGSDIALOG_H

View File

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SBI_SettingsDialog</class>
<widget class="QWidget" name="SBI_SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<height>186</height>
</rect>
</property>
<property name="windowTitle">
<string>StatusBar Icons</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap">
<pixmap resource="statusbaricons.qrc">:/sbi/data/icon.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;h3&gt;StatusBar Icons&lt;/h3&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>These icons will be displayed in statusbar:</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="showImagesIcon">
<property name="text">
<string>Images Icon</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showJavaScriptIcon">
<property name="text">
<string>JavaScript Icon</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showNetworkIcon">
<property name="text">
<string>Network Icon</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="statusbaricons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -17,6 +17,7 @@
* ============================================================ */
#include "statusbariconsplugin.h"
#include "sbi_iconsmanager.h"
#include "sbi_settingsdialog.h"
#include "pluginproxy.h"
#include "qupzilla.h"
@ -37,7 +38,7 @@ PluginSpec StatusBarIconsPlugin::pluginSpec()
spec.version = "0.1.5";
spec.author = "David Rosca <nowrep@gmail.com>";
spec.icon = QPixmap(":sbi/data/icon.png");
spec.hasSettings = false;
spec.hasSettings = true;
return spec;
}
@ -76,7 +77,8 @@ bool StatusBarIconsPlugin::testPlugin()
void StatusBarIconsPlugin::showSettings(QWidget* parent)
{
Q_UNUSED(parent)
SBI_SettingsDialog dialog(m_manager, parent);
dialog.exec();
}
#if QT_VERSION < 0x050000