1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Changed appearance of plugin list in Preferences.

This commit is contained in:
nowrep 2012-02-25 12:34:16 +01:00
parent 783d49ce64
commit 6eac428266
17 changed files with 133 additions and 12 deletions

View File

@ -159,7 +159,8 @@ SOURCES += \
popupwindow/popuplocationbar.cpp \
webview/tabbedwebview.cpp \
webview/webview.cpp \
webview/webviewsettings.cpp
webview/webviewsettings.cpp \
preferences/pluginlistdelegate.cpp
HEADERS += \
3rdparty/qtwin.h \
@ -292,7 +293,8 @@ HEADERS += \
webview/tabbedwebview.h \
webview/webview.h \
app/qz_namespace.h \
webview/webviewsettings.h
webview/webviewsettings.h \
preferences/pluginlistdelegate.h
FORMS += \
preferences/autofillmanager.ui \
@ -333,7 +335,8 @@ FORMS += \
preferences/addacceptlanguage.ui \
opensearch/searchenginesdialog.ui \
opensearch/editsearchengine.ui \
bookmarksimport/bookmarksimportdialog.ui
bookmarksimport/bookmarksimportdialog.ui \
preferences/pluginwidget.ui
RESOURCES += \
data/icons.qrc \

View File

@ -0,0 +1,45 @@
#include "pluginlistdelegate.h"
PluginListDelegate::PluginListDelegate(QListWidget* parent)
: QItemDelegate(parent)
, m_listWidget(parent)
{
}
void PluginListDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
{
QTextDocument textDocument;
textDocument.setHtml(text);
QTextLayout textLayout(textDocument.begin());
textLayout.setFont(option.font);
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0) + 1;
QRect textRect = rect.adjusted(textMargin, 0, -textMargin, 0); // remove width padding
textLayout.beginLayout();
qreal height = 0;
while (1) {
QTextLine line = textLayout.createLine();
if (!line.isValid()) {
break;
}
line.setLineWidth(textRect.width());
height += 3;
line.setPosition(QPoint(0, height));
height += line.height();
}
textLayout.endLayout();
textLayout.draw(painter, QPointF(textRect.left(), textRect.top()));
}
QSize PluginListDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QSize size = QItemDelegate::sizeHint(option, index);
size.setWidth(m_listWidget->width() - 5);
size.setHeight(option.fontMetrics.height() * 4);
return size;
}

View File

@ -0,0 +1,24 @@
#ifndef PLUGINLISTDELEGATE_H
#define PLUGINLISTDELEGATE_H
#include <QItemDelegate>
#include <QPainter>
#include <QTextDocument>
#include <QTextLayout>
#include <QTextBlock>
#include <QListWidget>
#include <QApplication>
class PluginListDelegate : public QItemDelegate
{
public:
PluginListDelegate(QListWidget* parent);
void drawDisplay(QPainter* painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const;
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
private:
QListWidget* m_listWidget;
};
#endif // PLUGINLISTDELEGATE_H

View File

@ -20,6 +20,7 @@
#include "pluginproxy.h"
#include "mainapplication.h"
#include "plugininterface.h"
#include "pluginlistdelegate.h"
#include "settings.h"
#ifdef PORTABLE_BUILD
@ -46,6 +47,8 @@ PluginsList::PluginsList(QWidget* parent)
connect(ui->list, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
connect(ui->allowAppPlugins, SIGNAL(clicked(bool)), this, SLOT(allowAppPluginsChanged(bool)));
ui->list->setItemDelegateForColumn(0, new PluginListDelegate(ui->list));
//WebKit Plugins
connect(ui->add, SIGNAL(clicked()), this, SLOT(addWhitelist()));
connect(ui->remove, SIGNAL(clicked()), this, SLOT(removeWhitelist()));
@ -148,9 +151,10 @@ void PluginsList::refresh()
PluginSpec spec = plugin.pluginSpec;
QListWidgetItem* item = new QListWidgetItem(ui->list);
QString pluginInfo = tr("%1 (%2)\nAuthor: %3\n%4\n%5").arg(spec.name, spec.version, spec.author, spec.info, spec.description);
QString pluginInfo = QString("<b>%1</b> %2 (%3)<br/>%4<br/>%5").arg(spec.name, spec.version, spec.author, spec.info, spec.description);
item->setText(pluginInfo);
QIcon icon = QIcon(spec.icon);
if (icon.isNull()) {
icon = QIcon(":/icons/preferences/extension.png");

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PluginWidget</class>
<widget class="QWidget" name="PluginWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>560</width>
<height>122</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>40</x>
<y>10</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>&lt;b&gt;Plugin Name&lt;/b&gt; 0.1.0</string>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>40</x>
<y>50</y>
<width>221</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -685,14 +685,14 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
QString langCode = mApp->getActiveLanguage().left(2);
QUrl googleTranslateUrl = QUrl(QString("http://translate.google.com/#auto|%1|%2").arg(langCode, selectedText));
Action* gtwact = new Action(QIcon(":icons/menu/translate.png"), tr("Google Translate"));
gtwact->setData(googleTranslateUrl);
connect(gtwact, SIGNAL(triggered()), this, SLOT(openUrlInSelectedTab()));
connect(gtwact, SIGNAL(middleClicked()), this, SLOT(openUrlInBackgroundTab()));
gtwact->setData(googleTranslateUrl);
connect(gtwact, SIGNAL(triggered()), this, SLOT(openUrlInSelectedTab()));
connect(gtwact, SIGNAL(middleClicked()), this, SLOT(openUrlInBackgroundTab()));
menu->addAction(gtwact);
Action* dictact = new Action(QIcon::fromTheme("accessories-dictionary"), tr("Dictionary"));
dictact->setData("http://" + (langCode != "" ? langCode + "." : langCode) + "wiktionary.org/wiki/Special:Search?search=" + selectedText);
connect(dictact, SIGNAL(triggered()), this, SLOT(openUrlInSelectedTab()));
connect(dictact, SIGNAL(middleClicked()), this, SLOT(openUrlInBackgroundTab()));
dictact->setData("http://" + (langCode != "" ? langCode + "." : langCode) + "wiktionary.org/wiki/Special:Search?search=" + selectedText);
connect(dictact, SIGNAL(triggered()), this, SLOT(openUrlInSelectedTab()));
connect(dictact, SIGNAL(middleClicked()), this, SLOT(openUrlInBackgroundTab()));
menu->addAction(dictact);
QString selectedString = selectedText.trimmed();
@ -718,7 +718,7 @@ void WebView::createSelectedTextContextMenu(QMenu* menu, const QWebHitTestResult
QMenu* swMenu = new QMenu(tr("Search with..."));
SearchEnginesManager* searchManager = mApp->searchEnginesManager();
foreach(const SearchEngine & en, searchManager->allEngines()) {
swMenu->addAction(en.icon, en.name, this, SLOT(searchSelectedText()))->setData(qVariantFromValue(en));
swMenu->addAction(en.icon, en.name, this, SLOT(searchSelectedText()))->setData(qVariantFromValue(en));
}
menu->addMenu(swMenu);
}

View File

@ -93,7 +93,7 @@ bool MouseGestureRecognizer::endGesture(int x, int y)
int dx = x - d->positions.at(0).x;
int dy = y - d->positions.at(0).y;
if (dx* dx + dy* dy < d->minimumMovement2) {
if (dx * dx + dy * dy < d->minimumMovement2) {
return false;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

After

Width:  |  Height:  |  Size: 428 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 328 B

After

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 322 B

After

Width:  |  Height:  |  Size: 381 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 429 B

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 383 B