mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
PluginsList: Sorting plugins alphabetically
This commit is contained in:
parent
0d4078f005
commit
189193a8b8
@ -66,7 +66,6 @@ SOURCES += \
|
||||
app/commandlineoptions.cpp \
|
||||
other/aboutdialog.cpp \
|
||||
plugins/plugins.cpp \
|
||||
preferences/pluginslist.cpp \
|
||||
plugins/pluginproxy.cpp \
|
||||
tools/clickablelabel.cpp \
|
||||
downloads/downloadoptionsdialog.cpp \
|
||||
@ -180,7 +179,8 @@ SOURCES += \
|
||||
adblock/adblockaddsubscriptiondialog.cpp \
|
||||
adblock/adblockschemehandler.cpp \
|
||||
tools/emptynetworkreply.cpp \
|
||||
3rdparty/processinfo.cpp
|
||||
3rdparty/processinfo.cpp \
|
||||
preferences/pluginsmanager.cpp
|
||||
|
||||
HEADERS += \
|
||||
webview/tabpreview.h \
|
||||
@ -215,7 +215,6 @@ HEADERS += \
|
||||
other/aboutdialog.h \
|
||||
plugins/plugininterface.h \
|
||||
plugins/plugins.h \
|
||||
preferences/pluginslist.h \
|
||||
plugins/pluginproxy.h \
|
||||
tools/clickablelabel.h \
|
||||
downloads/downloadoptionsdialog.h \
|
||||
@ -333,7 +332,8 @@ HEADERS += \
|
||||
adblock/adblockaddsubscriptiondialog.h \
|
||||
adblock/adblockschemehandler.h \
|
||||
tools/emptynetworkreply.h \
|
||||
3rdparty/processinfo.h
|
||||
3rdparty/processinfo.h \
|
||||
preferences/pluginsmanager.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
@ -45,6 +45,9 @@
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="verticalScrollMode">
|
||||
<enum>QAbstractItemView::ScrollPerPixel</enum>
|
||||
</property>
|
||||
<property name="uniformItemSizes">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -15,7 +15,7 @@
|
||||
* 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 "pluginslist.h"
|
||||
#include "pluginsmanager.h"
|
||||
#include "ui_pluginslist.h"
|
||||
#include "pluginproxy.h"
|
||||
#include "mainapplication.h"
|
||||
@ -28,9 +28,10 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
|
||||
PluginsList::PluginsList(QWidget* parent)
|
||||
PluginsManager::PluginsManager(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, ui(new Ui::PluginsList)
|
||||
, m_loaded(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@ -65,13 +66,17 @@ PluginsList::PluginsList(QWidget* parent)
|
||||
}
|
||||
|
||||
allowC2FChanged(ui->allowClick2Flash->isChecked());
|
||||
}
|
||||
|
||||
if (appPluginsEnabled) {
|
||||
QTimer::singleShot(0, this, SLOT(refresh()));
|
||||
void PluginsManager::load()
|
||||
{
|
||||
if (!m_loaded) {
|
||||
refresh();
|
||||
m_loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
void PluginsList::addWhitelist()
|
||||
void PluginsManager::addWhitelist()
|
||||
{
|
||||
QString site = QInputDialog::getText(this, tr("Add site to whitelist"), tr("Server without http:// (ex. youtube.com)"));
|
||||
if (site.isEmpty()) {
|
||||
@ -82,7 +87,7 @@ void PluginsList::addWhitelist()
|
||||
ui->whitelist->insertTopLevelItem(0, new QTreeWidgetItem(QStringList(site)));
|
||||
}
|
||||
|
||||
void PluginsList::removeWhitelist()
|
||||
void PluginsManager::removeWhitelist()
|
||||
{
|
||||
QTreeWidgetItem* item = ui->whitelist->currentItem();
|
||||
if (!item) {
|
||||
@ -93,7 +98,7 @@ void PluginsList::removeWhitelist()
|
||||
delete item;
|
||||
}
|
||||
|
||||
void PluginsList::save()
|
||||
void PluginsManager::save()
|
||||
{
|
||||
QStringList allowedPlugins;
|
||||
for (int i = 0; i < ui->list->count(); i++) {
|
||||
@ -113,14 +118,11 @@ void PluginsList::save()
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void PluginsList::allowAppPluginsChanged(bool state)
|
||||
void PluginsManager::allowAppPluginsChanged(bool state)
|
||||
{
|
||||
ui->list->setEnabled(state);
|
||||
|
||||
if (state) {
|
||||
refresh();
|
||||
}
|
||||
else {
|
||||
if (!state) {
|
||||
for (int i = 0; i < ui->list->count(); i++) {
|
||||
QListWidgetItem* item = ui->list->item(i);
|
||||
|
||||
@ -129,9 +131,11 @@ void PluginsList::allowAppPluginsChanged(bool state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
void PluginsList::allowC2FChanged(bool state)
|
||||
void PluginsManager::allowC2FChanged(bool state)
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("ClickToFlash");
|
||||
@ -145,8 +149,12 @@ void PluginsList::allowC2FChanged(bool state)
|
||||
mApp->plugins()->c2f_setEnabled(state);
|
||||
}
|
||||
|
||||
void PluginsList::refresh()
|
||||
void PluginsManager::refresh()
|
||||
{
|
||||
if (!ui->allowAppPlugins->isChecked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ui->list->clear();
|
||||
ui->butSettings->setEnabled(false);
|
||||
disconnect(ui->list, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
@ -178,10 +186,36 @@ void PluginsList::refresh()
|
||||
ui->list->addItem(item);
|
||||
}
|
||||
|
||||
sortItems();
|
||||
|
||||
connect(ui->list, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void PluginsList::currentChanged(QListWidgetItem* item)
|
||||
void PluginsManager::sortItems()
|
||||
{
|
||||
ui->list->sortItems();
|
||||
|
||||
bool itemMoved;
|
||||
do {
|
||||
itemMoved = false;
|
||||
for (int i = 0; i < ui->list->count(); ++i) {
|
||||
QListWidgetItem* topItem = ui->list->item(i);
|
||||
QListWidgetItem* bottomItem = ui->list->item(i + 1);
|
||||
if (!topItem || !bottomItem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (topItem->checkState() == Qt::Unchecked && bottomItem->checkState() == Qt::Checked) {
|
||||
QListWidgetItem* item = ui->list->takeItem(i + 1);
|
||||
ui->list->insertItem(i, item);
|
||||
itemMoved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (itemMoved);
|
||||
}
|
||||
|
||||
void PluginsManager::currentChanged(QListWidgetItem* item)
|
||||
{
|
||||
if (!item) {
|
||||
return;
|
||||
@ -197,7 +231,7 @@ void PluginsList::currentChanged(QListWidgetItem* item)
|
||||
ui->butSettings->setEnabled(showSettings);
|
||||
}
|
||||
|
||||
void PluginsList::itemChanged(QListWidgetItem* item)
|
||||
void PluginsManager::itemChanged(QListWidgetItem* item)
|
||||
{
|
||||
if (!item) {
|
||||
return;
|
||||
@ -227,7 +261,7 @@ void PluginsList::itemChanged(QListWidgetItem* item)
|
||||
currentChanged(ui->list->currentItem());
|
||||
}
|
||||
|
||||
void PluginsList::settingsClicked()
|
||||
void PluginsManager::settingsClicked()
|
||||
{
|
||||
QListWidgetItem* item = ui->list->currentItem();
|
||||
if (!item) {
|
||||
@ -247,7 +281,7 @@ void PluginsList::settingsClicked()
|
||||
}
|
||||
}
|
||||
|
||||
PluginsList::~PluginsList()
|
||||
PluginsManager::~PluginsManager()
|
||||
{
|
||||
delete ui;
|
||||
}
|
@ -15,8 +15,8 @@
|
||||
* 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 PLUGINSLIST_H
|
||||
#define PLUGINSLIST_H
|
||||
#ifndef PLUGINSMANAGER_H
|
||||
#define PLUGINSMANAGER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@ -29,13 +29,15 @@ class PluginsList;
|
||||
|
||||
class QListWidgetItem;
|
||||
|
||||
class QT_QUPZILLA_EXPORT PluginsList : public QWidget
|
||||
class QT_QUPZILLA_EXPORT PluginsManager : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PluginsList(QWidget* parent = 0);
|
||||
~PluginsList();
|
||||
explicit PluginsManager(QWidget* parent = 0);
|
||||
~PluginsManager();
|
||||
|
||||
void load();
|
||||
void save();
|
||||
|
||||
private slots:
|
||||
@ -52,9 +54,11 @@ private slots:
|
||||
void removeWhitelist();
|
||||
void allowC2FChanged(bool state);
|
||||
|
||||
private:;
|
||||
private:
|
||||
void sortItems();
|
||||
|
||||
Ui::PluginsList* ui;
|
||||
bool m_loaded;
|
||||
};
|
||||
|
||||
#endif // PLUGINSLIST_H
|
||||
#endif // PLUGINSMANAGER_H
|
@ -27,7 +27,7 @@
|
||||
#include "mainapplication.h"
|
||||
#include "cookiemanager.h"
|
||||
#include "pluginproxy.h"
|
||||
#include "pluginslist.h"
|
||||
#include "pluginsmanager.h"
|
||||
#include "qtwin.h"
|
||||
#include "sslmanager.h"
|
||||
#include "networkproxyfactory.h"
|
||||
@ -316,7 +316,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
|
||||
settings.endGroup();
|
||||
|
||||
//PLUGINS
|
||||
m_pluginsList = new PluginsList(this);
|
||||
m_pluginsList = new PluginsManager(this);
|
||||
ui->pluginsFrame->addWidget(m_pluginsList);
|
||||
|
||||
//NOTIFICATIONS
|
||||
@ -427,10 +427,15 @@ void Preferences::showStackedPage(QListWidgetItem* item)
|
||||
return;
|
||||
}
|
||||
|
||||
ui->caption->setText("<b>" + item->text() + "</b>");
|
||||
ui->stackedWidget->setCurrentIndex(ui->listWidget->currentRow());
|
||||
int index = ui->listWidget->currentRow();
|
||||
|
||||
setNotificationPreviewVisible(ui->stackedWidget->currentIndex() == 8);
|
||||
ui->caption->setText("<b>" + item->text() + "</b>");
|
||||
ui->stackedWidget->setCurrentIndex(index);
|
||||
|
||||
setNotificationPreviewVisible(index == 8);
|
||||
if (index == 9) {
|
||||
m_pluginsList->load();
|
||||
}
|
||||
}
|
||||
|
||||
void Preferences::setNotificationPreviewVisible(bool state)
|
||||
|
@ -33,7 +33,7 @@ class QListWidgetItem;
|
||||
|
||||
class AutoFillManager;
|
||||
class QupZilla;
|
||||
class PluginsList;
|
||||
class PluginsManager;
|
||||
class DesktopNotification;
|
||||
class ThemeManager;
|
||||
|
||||
@ -89,7 +89,7 @@ private:
|
||||
Ui::Preferences* ui;
|
||||
QupZilla* p_QupZilla;
|
||||
AutoFillManager* m_autoFillManager;
|
||||
PluginsList* m_pluginsList;
|
||||
PluginsManager* m_pluginsList;
|
||||
ThemeManager* m_themesManager;
|
||||
QWeakPointer<DesktopNotification> m_notification;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user