mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
This commit is contained in:
commit
3dc43b18a3
Binary file not shown.
@ -171,8 +171,7 @@
|
||||
#bookmarksbar QToolButton
|
||||
{
|
||||
border-image: url(images/transp.png);
|
||||
border-width: 1px;
|
||||
padding-right: -5px;
|
||||
border-width: 0px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
|
@ -209,8 +209,7 @@
|
||||
#bookmarksbar QToolButton
|
||||
{
|
||||
border-image: url(images/transp.png);
|
||||
border-width: 1px;
|
||||
padding-right: -5px;
|
||||
border-width: 0px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,7 @@
|
||||
|
||||
#locationbar[secured="true"]
|
||||
{
|
||||
color: black;
|
||||
background-color: #ffffbc;
|
||||
}
|
||||
|
||||
@ -161,8 +162,7 @@
|
||||
#bookmarksbar QToolButton
|
||||
{
|
||||
border-image: url(images/transp.png);
|
||||
border-width: 1px;
|
||||
padding-right: -5px;
|
||||
border-width: 0px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
|
@ -165,8 +165,7 @@
|
||||
#bookmarksbar QToolButton
|
||||
{
|
||||
border-image: url(images/transp.png);
|
||||
border-width: 1px;
|
||||
padding-right: -5px;
|
||||
border-width: 0px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,7 @@
|
||||
#bookmarksbar QToolButton
|
||||
{
|
||||
border-image: url(images/transp.png);
|
||||
border-width: 1px;
|
||||
padding-right: -5px;
|
||||
border-width: 0px;
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
|
@ -4,5 +4,7 @@ lupdate ../src/plugins/TestPlugin/TestPlugin.pro -no-obsolete
|
||||
|
||||
lupdate ../src/plugins/MouseGestures/MouseGestures.pro -no-obsolete
|
||||
|
||||
lupdate ../src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro -no-obsolete
|
||||
|
||||
read -p "Press [ENTER] to close terminal"
|
||||
exit
|
||||
|
2
src/lib/3rdparty/qtsingleapplication.pri
vendored
2
src/lib/3rdparty/qtsingleapplication.pri
vendored
@ -9,7 +9,7 @@ qtsingleapplication-uselib:!qtsingleapplication-buildlib {
|
||||
HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h
|
||||
}
|
||||
|
||||
win32 {
|
||||
os2|win32 {
|
||||
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT
|
||||
else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT
|
||||
}
|
||||
|
@ -57,8 +57,10 @@ AdBlockNetwork::AdBlockNetwork(QObject* parent)
|
||||
|
||||
QNetworkReply* AdBlockNetwork::block(const QNetworkRequest &request)
|
||||
{
|
||||
QUrl url = request.url();
|
||||
if (url.scheme() == "data" || url.scheme() == "qrc" || url.scheme() == "file" || url.scheme() == "qupzilla") {
|
||||
const QString &urlString = request.url().toEncoded();
|
||||
const QString &urlScheme = request.url().scheme();
|
||||
|
||||
if (urlScheme == "data" || urlScheme == "qrc" || urlScheme == "file" || urlScheme == "qupzilla") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -67,7 +69,6 @@ QNetworkReply* AdBlockNetwork::block(const QNetworkRequest &request)
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString urlString = url.toEncoded();
|
||||
const AdBlockRule* blockedRule = 0;
|
||||
AdBlockSubscription* subscription = manager->subscription();
|
||||
|
||||
|
@ -624,7 +624,6 @@ void MainApplication::saveSettings()
|
||||
}
|
||||
|
||||
m_searchEnginesManager->saveSettings();
|
||||
m_cookiejar->saveCookies();
|
||||
m_networkmanager->saveCertificates();
|
||||
m_plugins->c2f_saveSettings();
|
||||
m_plugins->speedDial()->saveSettings();
|
||||
@ -803,6 +802,9 @@ bool MainApplication::saveStateSlot()
|
||||
qupzilla_->tabWidget()->savePinnedTabs();
|
||||
}
|
||||
|
||||
// Saving cookies
|
||||
m_cookiejar->saveCookies();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -198,9 +198,10 @@ void QupZilla::postLaunch()
|
||||
}
|
||||
|
||||
aboutToHideEditMenu();
|
||||
|
||||
setUpdatesEnabled(true);
|
||||
|
||||
mApp->plugins()->emitMainWindowCreated(this);
|
||||
|
||||
emit startingCompleted();
|
||||
}
|
||||
|
||||
@ -1416,7 +1417,13 @@ void QupZilla::searchOnPage()
|
||||
|
||||
void QupZilla::openFile()
|
||||
{
|
||||
const QString &filePath = QFileDialog::getOpenFileName(this, tr("Open file..."), QDir::homePath(), "(*.html *.htm *.jpg *.png)");
|
||||
const QString &fileTypes = QString("%1(*.html *.htm *.shtml *.shtm);;"
|
||||
"%2(*.txt);;"
|
||||
"%3(*.png *.jpg *.jpeg *.bmp *.gif *.svg);;"
|
||||
"%4(*.*)").arg(tr("HTML files"), tr("Image files"), tr("Text files"), tr("All files"));
|
||||
|
||||
const QString &filePath = QFileDialog::getOpenFileName(this, tr("Open file..."), QDir::homePath(), fileTypes);
|
||||
|
||||
if (!filePath.isEmpty()) {
|
||||
loadAddress(QUrl::fromLocalFile(filePath));
|
||||
}
|
||||
@ -1542,6 +1549,7 @@ void QupZilla::startPrivate(bool state)
|
||||
QMessageBox::StandardButton button = QMessageBox::question(this, tr("Start Private Browsing"),
|
||||
message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
|
||||
if (button != QMessageBox::Yes) {
|
||||
m_actionPrivateBrowsing->setChecked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1560,6 +1568,10 @@ void QupZilla::resizeEvent(QResizeEvent* event)
|
||||
|
||||
void QupZilla::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (mApp->plugins()->processKeyPress(Qz::ON_QupZilla, this, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
int number = -1;
|
||||
|
||||
switch (event->key()) {
|
||||
@ -1688,6 +1700,15 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
|
||||
QMainWindow::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void QupZilla::keyReleaseEvent(QKeyEvent* event)
|
||||
{
|
||||
if (mApp->plugins()->processKeyRelease(Qz::ON_QupZilla, this, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMainWindow::keyReleaseEvent(event);
|
||||
}
|
||||
|
||||
void QupZilla::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
if (mApp->isClosing()) {
|
||||
@ -1744,6 +1765,8 @@ void QupZilla::disconnectObjects()
|
||||
pointer.data()->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
mApp->plugins()->emitMainWindowDeleted(this);
|
||||
}
|
||||
|
||||
void QupZilla::closeWindow()
|
||||
|
@ -194,6 +194,7 @@ private slots:
|
||||
private:
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void keyReleaseEvent(QKeyEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
void setupUi();
|
||||
|
@ -41,7 +41,6 @@ enum CommandLineAction {
|
||||
|
||||
enum ObjectName {
|
||||
ON_WebView,
|
||||
ON_TabWidget,
|
||||
ON_TabBar,
|
||||
ON_QupZilla
|
||||
};
|
||||
|
@ -102,6 +102,12 @@ void BookmarkIcon::setBookmarkDisabled()
|
||||
setToolTip(tr("Bookmark this Page"));
|
||||
}
|
||||
|
||||
void BookmarkIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
void BookmarkIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -41,6 +41,7 @@ private slots:
|
||||
void speedDialChanged();
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
||||
void setBookmarkSaved();
|
||||
|
@ -63,6 +63,16 @@ void BookmarksModel::setShowingOnlyIconsInToolbar(bool state)
|
||||
m_showOnlyIconsInToolbar = state;
|
||||
}
|
||||
|
||||
bool BookmarksModel::isFolder(const QString &name)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT name FROM folders WHERE name = ?");
|
||||
query.bindValue(0, name);
|
||||
query.exec();
|
||||
|
||||
return query.next();
|
||||
}
|
||||
|
||||
void BookmarksModel::setLastFolder(const QString &folder)
|
||||
{
|
||||
Settings settings;
|
||||
@ -154,6 +164,10 @@ bool BookmarksModel::saveBookmark(const QUrl &url, const QString &title, const Q
|
||||
image = QWebSettings::webGraphic(QWebSettings::DefaultFrameIconGraphic).toImage();
|
||||
}
|
||||
|
||||
if (!isFolder(folder)) {
|
||||
createFolder(folder);
|
||||
}
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("INSERT INTO bookmarks (url, title, folder, icon) VALUES (?,?,?,?)");
|
||||
query.bindValue(0, url.toString());
|
||||
@ -292,14 +306,11 @@ bool BookmarksModel::editBookmark(int id, const QString &title, const QUrl &url,
|
||||
|
||||
bool BookmarksModel::createFolder(const QString &name)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT name FROM folders WHERE name = ?");
|
||||
query.bindValue(0, name);
|
||||
query.exec();
|
||||
if (query.next()) {
|
||||
if (isFolder(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("INSERT INTO folders (name, subfolder) VALUES (?, 'no')");
|
||||
query.bindValue(0, name);
|
||||
if (!query.exec()) {
|
||||
@ -397,14 +408,11 @@ QList<Bookmark> BookmarksModel::folderBookmarks(const QString &name)
|
||||
|
||||
bool BookmarksModel::createSubfolder(const QString &name)
|
||||
{
|
||||
QSqlQuery query;
|
||||
query.prepare("SELECT name FROM folders WHERE name = ?");
|
||||
query.bindValue(0, name);
|
||||
query.exec();
|
||||
if (query.next()) {
|
||||
if (isFolder(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QSqlQuery query;
|
||||
query.prepare("INSERT INTO folders (name, subfolder) VALUES (?, 'yes')");
|
||||
query.bindValue(0, name);
|
||||
if (!query.exec()) {
|
||||
|
@ -68,6 +68,7 @@ public:
|
||||
bool isShowingOnlyIconsInToolbar() { return m_showOnlyIconsInToolbar; }
|
||||
void setShowingOnlyIconsInToolbar(bool state);
|
||||
|
||||
bool isFolder(const QString &name);
|
||||
QString lastFolder() { return m_lastFolder; }
|
||||
void setLastFolder(const QString &folder);
|
||||
|
||||
|
@ -44,7 +44,7 @@ BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
|
||||
{
|
||||
setObjectName("bookmarksbar");
|
||||
m_layout = new QHBoxLayout();
|
||||
m_layout->setContentsMargins(9, 3, 9, 3);
|
||||
m_layout->setMargin(3);
|
||||
m_layout->setSpacing(0);
|
||||
setLayout(m_layout);
|
||||
|
||||
@ -339,7 +339,7 @@ void BookmarksToolbar::subfolderAdded(const QString &name)
|
||||
{
|
||||
ToolButton* b = new ToolButton(this);
|
||||
b->setPopupMode(QToolButton::InstantPopup);
|
||||
b->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
b->setToolButtonStyle(m_toolButtonStyle);
|
||||
b->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
|
||||
b->setText(name);
|
||||
connect(b, SIGNAL(middleMouseClicked()), this, SLOT(loadFolderBookmarksInTabs()));
|
||||
@ -404,7 +404,7 @@ void BookmarksToolbar::addBookmark(const BookmarksModel::Bookmark &bookmark)
|
||||
button->setText(title);
|
||||
button->setData(v);
|
||||
button->setIcon(IconProvider::iconFromImage(bookmark.image));
|
||||
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
button->setToolButtonStyle(m_toolButtonStyle);
|
||||
button->setToolTip(bookmark.url.toEncoded());
|
||||
button->setAutoRaise(true);
|
||||
button->setWhatsThis(bookmark.title);
|
||||
@ -504,7 +504,7 @@ void BookmarksToolbar::refreshBookmarks()
|
||||
button->setText(title);
|
||||
button->setData(v);
|
||||
button->setIcon(IconProvider::iconFromImage(bookmark.image));
|
||||
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
button->setToolButtonStyle(m_toolButtonStyle);
|
||||
button->setToolTip(bookmark.url.toEncoded());
|
||||
button->setWhatsThis(bookmark.title);
|
||||
button->setAutoRaise(true);
|
||||
@ -521,7 +521,7 @@ void BookmarksToolbar::refreshBookmarks()
|
||||
while (query.next()) {
|
||||
ToolButton* b = new ToolButton(this);
|
||||
b->setPopupMode(QToolButton::InstantPopup);
|
||||
b->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
b->setToolButtonStyle(m_toolButtonStyle);
|
||||
b->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
|
||||
b->setText(query.value(0).toString());
|
||||
connect(b, SIGNAL(middleMouseClicked()), this, SLOT(loadFolderBookmarksInTabs()));
|
||||
@ -535,7 +535,7 @@ void BookmarksToolbar::refreshBookmarks()
|
||||
|
||||
m_mostVis = new ToolButton(this);
|
||||
m_mostVis->setPopupMode(QToolButton::InstantPopup);
|
||||
m_mostVis->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
m_mostVis->setToolButtonStyle(m_toolButtonStyle);
|
||||
m_mostVis->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
|
||||
m_mostVis->setText(tr("Most visited"));
|
||||
m_mostVis->setToolTip(tr("Sites you visited the most"));
|
||||
@ -579,35 +579,6 @@ void BookmarksToolbar::aboutToShowFolderMenu()
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::dragEnterEvent(QDragEnterEvent* e)
|
||||
{
|
||||
const QMimeData* mime = e->mimeData();
|
||||
|
||||
if (mime->hasUrls() || mime->hasText()) {
|
||||
e->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::dropEvent(e);
|
||||
}
|
||||
|
||||
void BookmarksToolbar::showOnlyIconsChanged()
|
||||
{
|
||||
Qt::ToolButtonStyle iconStyle = Qt::ToolButtonTextBesideIcon;
|
||||
if (m_bookmarksModel->isShowingOnlyIconsInToolbar()) {
|
||||
iconStyle = Qt::ToolButtonIconOnly;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_layout->count(); ++i) {
|
||||
ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget());
|
||||
if (!button) {
|
||||
continue;
|
||||
}
|
||||
|
||||
button->setToolButtonStyle(iconStyle);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::dropEvent(QDropEvent* e)
|
||||
{
|
||||
const QMimeData* mime = e->mimeData();
|
||||
@ -624,6 +595,35 @@ void BookmarksToolbar::dropEvent(QDropEvent* e)
|
||||
m_bookmarksModel->saveBookmark(url, title, icon, "bookmarksToolbar");
|
||||
}
|
||||
|
||||
void BookmarksToolbar::dragEnterEvent(QDragEnterEvent* e)
|
||||
{
|
||||
const QMimeData* mime = e->mimeData();
|
||||
|
||||
if (mime->hasUrls() && mime->hasText()) {
|
||||
e->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget::dragEnterEvent(e);
|
||||
}
|
||||
|
||||
void BookmarksToolbar::showOnlyIconsChanged()
|
||||
{
|
||||
m_toolButtonStyle = Qt::ToolButtonTextBesideIcon;
|
||||
if (m_bookmarksModel->isShowingOnlyIconsInToolbar()) {
|
||||
m_toolButtonStyle = Qt::ToolButtonIconOnly;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_layout->count(); ++i) {
|
||||
ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget());
|
||||
if (!button) {
|
||||
continue;
|
||||
}
|
||||
|
||||
button->setToolButtonStyle(m_toolButtonStyle);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::refreshMostVisited()
|
||||
{
|
||||
m_menuMostVisited->clear();
|
||||
|
@ -81,6 +81,8 @@ private:
|
||||
Menu* m_menuMostVisited;
|
||||
ToolButton* m_mostVis;
|
||||
QHBoxLayout* m_layout;
|
||||
|
||||
Qt::ToolButtonStyle m_toolButtonStyle;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKSTOOLBAR_H
|
||||
|
@ -22,18 +22,21 @@
|
||||
#include "operaimporter.h"
|
||||
#include "htmlimporter.h"
|
||||
#include "mainapplication.h"
|
||||
#include "iconfetcher.h"
|
||||
#include "bookmarksimporticonfetcher.h"
|
||||
#include "iconprovider.h"
|
||||
#include "networkmanager.h"
|
||||
|
||||
#include <QWebSettings>
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QThread>
|
||||
|
||||
BookmarksImportDialog::BookmarksImportDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::BookmarksImportDialog)
|
||||
, m_currentPage(0)
|
||||
, m_fetcher(0)
|
||||
, m_fetcherThread(0)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(this);
|
||||
@ -96,28 +99,53 @@ void BookmarksImportDialog::startFetchingIcons()
|
||||
ui->progressBar->setValue(0);
|
||||
ui->progressBar->setMaximum(m_exportedBookmarks.count());
|
||||
|
||||
int i = 0;
|
||||
m_fetcherThread = new QThread();
|
||||
m_fetcher = new BookmarksImportIconFetcher();
|
||||
m_fetcher->moveToThread(m_fetcherThread);
|
||||
|
||||
QIcon defaultIcon = QIcon(QWebSettings::globalSettings()->webGraphic(QWebSettings::DefaultFrameIconGraphic));
|
||||
QIcon folderIcon = style()->standardIcon(QStyle::SP_DirIcon);
|
||||
QHash<QString, QTreeWidgetItem*> hash;
|
||||
|
||||
foreach(const Bookmark & b, m_exportedBookmarks) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
QTreeWidgetItem* item;
|
||||
QTreeWidgetItem* findParent = hash[b.folder];
|
||||
if (findParent) {
|
||||
item = new QTreeWidgetItem(findParent);
|
||||
}
|
||||
else {
|
||||
QTreeWidgetItem* newParent = new QTreeWidgetItem(ui->treeWidget);
|
||||
newParent->setText(0, b.folder);
|
||||
newParent->setIcon(0, folderIcon);
|
||||
ui->treeWidget->addTopLevelItem(newParent);
|
||||
hash[b.folder] = newParent;
|
||||
|
||||
item = new QTreeWidgetItem(newParent);
|
||||
}
|
||||
|
||||
QVariant bookmarkVariant = qVariantFromValue(b);
|
||||
item->setText(0, b.title);
|
||||
item->setIcon(0, QWebSettings::globalSettings()->webGraphic(QWebSettings::DefaultFrameIconGraphic));
|
||||
if (b.image.isNull()) {
|
||||
item->setIcon(0, defaultIcon);
|
||||
}
|
||||
else {
|
||||
item->setIcon(0, QIcon(QPixmap::fromImage(b.image)));
|
||||
}
|
||||
item->setText(1, b.url.toString());
|
||||
item->setWhatsThis(0, QString::number(i));
|
||||
item->setData(0, Qt::UserRole + 10, bookmarkVariant);
|
||||
|
||||
ui->treeWidget->addTopLevelItem(item);
|
||||
i++;
|
||||
|
||||
IconFetcher* fetcher = new IconFetcher(this);
|
||||
fetcher->setNetworkAccessManager(mApp->networkManager());
|
||||
connect(fetcher, SIGNAL(finished()), this, SLOT(loadFinished()));
|
||||
connect(fetcher, SIGNAL(iconFetched(QIcon)), this, SLOT(iconFetched(QIcon)));
|
||||
fetcher->fetchIcon(b.url);
|
||||
|
||||
QPair<IconFetcher*, QUrl> pair;
|
||||
pair.first = fetcher;
|
||||
pair.second = b.url;
|
||||
m_fetchers.append(pair);
|
||||
m_fetcher->addEntry(b.url, item);
|
||||
}
|
||||
|
||||
ui->treeWidget->expandAll();
|
||||
|
||||
connect(m_fetcher, SIGNAL(iconFetched(QImage, QTreeWidgetItem*)), this, SLOT(iconFetched(QImage, QTreeWidgetItem*)));
|
||||
connect(m_fetcher, SIGNAL(oneFinished()), this, SLOT(loadFinished()));
|
||||
|
||||
m_fetcherThread->start();
|
||||
m_fetcher->startFetching();
|
||||
}
|
||||
|
||||
void BookmarksImportDialog::stopDownloading()
|
||||
@ -139,42 +167,15 @@ void BookmarksImportDialog::loadFinished()
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksImportDialog::iconFetched(const QIcon &icon)
|
||||
void BookmarksImportDialog::iconFetched(const QImage &image, QTreeWidgetItem* item)
|
||||
{
|
||||
IconFetcher* fetcher = qobject_cast<IconFetcher*>(sender());
|
||||
if (!fetcher) {
|
||||
return;
|
||||
}
|
||||
item->setIcon(0, QIcon(QPixmap::fromImage(image)));
|
||||
|
||||
QUrl url;
|
||||
for (int i = 0; i < m_fetchers.count(); i++) {
|
||||
QPair<IconFetcher*, QUrl> pair = m_fetchers.at(i);
|
||||
if (pair.first == fetcher) {
|
||||
url = pair.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Bookmark b = item->data(0, Qt::UserRole + 10).value<Bookmark>();
|
||||
|
||||
if (url.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QTreeWidgetItem*> items = ui->treeWidget->findItems(url.toString(), Qt::MatchExactly, 1);
|
||||
if (items.count() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach(QTreeWidgetItem * item, items) {
|
||||
item->setIcon(0, icon);
|
||||
|
||||
foreach(Bookmark b, m_exportedBookmarks) {
|
||||
if (b.url == url) {
|
||||
m_exportedBookmarks.removeOne(b);
|
||||
b.image = icon.pixmap(16, 16).toImage();
|
||||
m_exportedBookmarks.append(b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
int index = m_exportedBookmarks.indexOf(b);
|
||||
if (index != -1) {
|
||||
m_exportedBookmarks[index].image = image;
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,10 +264,6 @@ void BookmarksImportDialog::addExportedBookmarks()
|
||||
|
||||
BookmarksModel* model = mApp->bookmarksModel();
|
||||
|
||||
if (m_exportedBookmarks.count() > 0) {
|
||||
model->createFolder(m_exportedBookmarks.at(0).folder);
|
||||
}
|
||||
|
||||
foreach(const Bookmark & b, m_exportedBookmarks) {
|
||||
model->saveBookmark(b.url, b.title, IconProvider::iconFromImage(b.image), b.folder);
|
||||
}
|
||||
@ -349,13 +346,13 @@ void BookmarksImportDialog::setupBrowser(Browser browser)
|
||||
|
||||
BookmarksImportDialog::~BookmarksImportDialog()
|
||||
{
|
||||
if (m_fetchers.count() > 0) {
|
||||
for (int i = 0; i < m_fetchers.count(); i++) {
|
||||
tr("");
|
||||
IconFetcher* fetcher = m_fetchers.at(i).first;
|
||||
fetcher->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
delete ui;
|
||||
|
||||
if (m_fetcherThread) {
|
||||
m_fetcherThread->exit();
|
||||
m_fetcherThread->wait();
|
||||
|
||||
m_fetcherThread->deleteLater();
|
||||
m_fetcher->deleteLater();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,11 @@ namespace Ui
|
||||
class BookmarksImportDialog;
|
||||
}
|
||||
|
||||
class IconFetcher;
|
||||
class QTreeWidgetItem;
|
||||
class QThread;
|
||||
|
||||
class BookmarksImportIconFetcher;
|
||||
|
||||
class QT_QUPZILLA_EXPORT BookmarksImportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -43,7 +47,7 @@ private slots:
|
||||
void setFile();
|
||||
|
||||
void stopDownloading();
|
||||
void iconFetched(const QIcon &icon);
|
||||
void iconFetched(const QImage &image, QTreeWidgetItem* item);
|
||||
void loadFinished();
|
||||
|
||||
private:
|
||||
@ -68,7 +72,8 @@ private:
|
||||
|
||||
QList<BookmarksModel::Bookmark> m_exportedBookmarks;
|
||||
|
||||
QList<QPair<IconFetcher*, QUrl> > m_fetchers;
|
||||
BookmarksImportIconFetcher* m_fetcher;
|
||||
QThread* m_fetcherThread;
|
||||
};
|
||||
|
||||
#endif // BOOKMARKSIMPORTDIALOG_H
|
||||
|
84
src/lib/bookmarksimport/bookmarksimporticonfetcher.cpp
Normal file
84
src/lib/bookmarksimport/bookmarksimporticonfetcher.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 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 "bookmarksimporticonfetcher.h"
|
||||
#include "iconfetcher.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
BookmarksImportIconFetcher::BookmarksImportIconFetcher(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void BookmarksImportIconFetcher::addEntry(const QUrl &url, QTreeWidgetItem* item)
|
||||
{
|
||||
Pair pair;
|
||||
pair.url = url;
|
||||
pair.item = item;
|
||||
|
||||
m_pairs.append(pair);
|
||||
}
|
||||
|
||||
void BookmarksImportIconFetcher::startFetching()
|
||||
{
|
||||
QTimer::singleShot(0, this, SLOT(slotStartFetching()));
|
||||
}
|
||||
|
||||
void BookmarksImportIconFetcher::slotIconFetched(const QImage &image)
|
||||
{
|
||||
IconFetcher* fetcher = qobject_cast<IconFetcher*>(sender());
|
||||
if (!fetcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem* itemPointer = static_cast<QTreeWidgetItem*>(fetcher->data().value<void*>());
|
||||
|
||||
emit iconFetched(image, itemPointer);
|
||||
}
|
||||
|
||||
void BookmarksImportIconFetcher::slotFetcherFinished()
|
||||
{
|
||||
IconFetcher* fetcher = qobject_cast<IconFetcher*>(sender());
|
||||
if (!fetcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_fetchers.removeOne(fetcher);
|
||||
|
||||
emit oneFinished();
|
||||
}
|
||||
|
||||
void BookmarksImportIconFetcher::slotStartFetching()
|
||||
{
|
||||
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
|
||||
|
||||
foreach(const Pair & pair, m_pairs) {
|
||||
QVariant itemPointer = qVariantFromValue((void*) pair.item);
|
||||
|
||||
IconFetcher* fetcher = new IconFetcher(this);
|
||||
fetcher->setNetworkAccessManager(manager);
|
||||
fetcher->setData(itemPointer);
|
||||
fetcher->fetchIcon(pair.url);
|
||||
|
||||
connect(fetcher, SIGNAL(iconFetched(QImage)), this, SLOT(slotIconFetched(QImage)));
|
||||
connect(fetcher, SIGNAL(finished()), this, SLOT(slotFetcherFinished()));
|
||||
|
||||
m_fetchers.append(fetcher);
|
||||
}
|
||||
}
|
63
src/lib/bookmarksimport/bookmarksimporticonfetcher.h
Normal file
63
src/lib/bookmarksimport/bookmarksimporticonfetcher.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 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 BOOKMARKSIMPORTICONFETCHER_H
|
||||
#define BOOKMARKSIMPORTICONFETCHER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QTreeWidgetItem;
|
||||
class QImage;
|
||||
|
||||
class IconFetcher;
|
||||
|
||||
class QT_QUPZILLA_EXPORT BookmarksImportIconFetcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct Pair {
|
||||
QUrl url;
|
||||
QTreeWidgetItem* item;
|
||||
};
|
||||
|
||||
explicit BookmarksImportIconFetcher(QObject* parent = 0);
|
||||
|
||||
void addEntry(const QUrl &url, QTreeWidgetItem* item);
|
||||
void startFetching();
|
||||
|
||||
signals:
|
||||
void iconFetched(const QImage &image, QTreeWidgetItem* item);
|
||||
void oneFinished();
|
||||
|
||||
private slots:
|
||||
void slotStartFetching();
|
||||
|
||||
void slotIconFetched(const QImage &image);
|
||||
void slotFetcherFinished();
|
||||
|
||||
private:
|
||||
QList<Pair> m_pairs;
|
||||
QList<IconFetcher*> m_fetchers;
|
||||
|
||||
};
|
||||
|
||||
#endif // BOOKMARKSIMPORTICONFETCHER_H
|
@ -53,7 +53,7 @@ QList<BookmarksModel::Bookmark> ChromeImporter::exportBookmarks()
|
||||
{
|
||||
QList<BookmarksModel::Bookmark> list;
|
||||
|
||||
QString bookmarks = m_file.readAll();
|
||||
QString bookmarks = QString::fromUtf8(m_file.readAll());
|
||||
m_file.close();
|
||||
|
||||
QStringList parsedBookmarks;
|
||||
|
@ -45,40 +45,91 @@ bool HtmlImporter::openFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
int qzMin(int a, int b)
|
||||
{
|
||||
if (a > -1 && b > -1) {
|
||||
return qMin(a, b);
|
||||
}
|
||||
|
||||
if (a > -1) {
|
||||
return a;
|
||||
}
|
||||
else {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
QList<BookmarksModel::Bookmark> HtmlImporter::exportBookmarks()
|
||||
{
|
||||
QList<BookmarksModel::Bookmark> list;
|
||||
|
||||
QString bookmarks = m_file.readAll();
|
||||
QString bookmarks = QString::fromUtf8(m_file.readAll());
|
||||
m_file.close();
|
||||
|
||||
QRegExp rx("<a (.*)</a>", Qt::CaseInsensitive);
|
||||
rx.setMinimal(true);
|
||||
bookmarks = bookmarks.mid(0, bookmarks.lastIndexOf("</DL><p>"));
|
||||
int start = bookmarks.indexOf("<DL><p>", Qt::CaseInsensitive);
|
||||
|
||||
int pos = 0;
|
||||
while ((pos = rx.indexIn(bookmarks, pos)) != -1) {
|
||||
QString string = rx.cap(0);
|
||||
pos += rx.matchedLength();
|
||||
QStringList folders("Html Import");
|
||||
|
||||
QRegExp rx2(">(.*)</a>", Qt::CaseInsensitive);
|
||||
rx2.setMinimal(true);
|
||||
rx2.indexIn(string);
|
||||
QString name = rx2.cap(1);
|
||||
while (start > 0) {
|
||||
QString string = bookmarks.mid(start);
|
||||
|
||||
rx2.setPattern("href=\"(.*)\"");
|
||||
rx2.indexIn(string);
|
||||
QUrl url = QUrl::fromEncoded(rx2.cap(1).toUtf8());
|
||||
int posOfFolder = string.indexOf("<DT><H3", Qt::CaseInsensitive);
|
||||
int posOfEndFolder = string.indexOf("</DL><p>", Qt::CaseInsensitive);
|
||||
int posOfLink = string.indexOf("<DT><A", Qt::CaseInsensitive);
|
||||
|
||||
if (name.isEmpty() || url.isEmpty() || url.scheme() == "place" || url.scheme() == "about") {
|
||||
continue;
|
||||
int nearest = qzMin(posOfLink, qzMin(posOfFolder, posOfEndFolder));
|
||||
if (nearest == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
BookmarksModel::Bookmark b;
|
||||
b.folder = "Html Import";
|
||||
b.title = name;
|
||||
b.url = url;
|
||||
if (nearest == posOfFolder) {
|
||||
// Next is folder
|
||||
QRegExp rx("<DT><H3(.*)>(.*)</H3>", Qt::CaseInsensitive);
|
||||
rx.setMinimal(true);
|
||||
rx.indexIn(string);
|
||||
|
||||
list.append(b);
|
||||
// QString arguments = rx.cap(1);
|
||||
QString folderName = rx.cap(2);
|
||||
|
||||
folders.append(folderName);
|
||||
|
||||
start += posOfFolder + rx.cap(0).size();
|
||||
}
|
||||
else if (nearest == posOfEndFolder) {
|
||||
// Next is end of folder
|
||||
folders.removeLast();
|
||||
|
||||
start += posOfEndFolder + 8;
|
||||
}
|
||||
else {
|
||||
// Next is link
|
||||
QRegExp rx("<DT><A(.*)>(.*)</A>", Qt::CaseInsensitive);
|
||||
rx.setMinimal(true);
|
||||
rx.indexIn(string);
|
||||
|
||||
QString arguments = rx.cap(1);
|
||||
QString linkName = rx.cap(2);
|
||||
|
||||
QRegExp rx2("HREF=\"(.*)\"", Qt::CaseInsensitive);
|
||||
rx2.setMinimal(true);
|
||||
rx2.indexIn(arguments);
|
||||
|
||||
QUrl url = QUrl::fromEncoded(rx2.cap(1).toUtf8());
|
||||
|
||||
start += posOfLink + rx.cap(0).size();
|
||||
|
||||
if (linkName.isEmpty() || url.isEmpty() || url.scheme() == "place" || url.scheme() == "about") {
|
||||
continue;
|
||||
}
|
||||
|
||||
BookmarksModel::Bookmark b;
|
||||
b.folder = folders.last();
|
||||
b.title = linkName;
|
||||
b.url = url;
|
||||
|
||||
list.append(b);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
|
@ -47,7 +47,7 @@ QList<BookmarksModel::Bookmark> OperaImporter::exportBookmarks()
|
||||
{
|
||||
QList<BookmarksModel::Bookmark> list;
|
||||
|
||||
QString bookmarks = m_file.readAll();
|
||||
QString bookmarks = QString::fromUtf8(m_file.readAll());
|
||||
m_file.close();
|
||||
|
||||
QRegExp rx("#URL(.*)CREATED", Qt::CaseSensitive);
|
||||
|
@ -163,7 +163,9 @@ SOURCES += \
|
||||
webview/webview.cpp \
|
||||
webview/webviewsettings.cpp \
|
||||
preferences/pluginlistdelegate.cpp \
|
||||
popupwindow/popupstatusbarmessage.cpp
|
||||
popupwindow/popupstatusbarmessage.cpp \
|
||||
other/licenseviewer.cpp \
|
||||
bookmarksimport/bookmarksimporticonfetcher.cpp
|
||||
|
||||
HEADERS += \
|
||||
3rdparty/qtwin.h \
|
||||
@ -298,7 +300,9 @@ HEADERS += \
|
||||
app/qz_namespace.h \
|
||||
webview/webviewsettings.h \
|
||||
preferences/pluginlistdelegate.h \
|
||||
popupwindow/popupstatusbarmessage.h
|
||||
popupwindow/popupstatusbarmessage.h \
|
||||
other/licenseviewer.h \
|
||||
bookmarksimport/bookmarksimporticonfetcher.h
|
||||
|
||||
FORMS += \
|
||||
preferences/autofillmanager.ui \
|
||||
|
@ -26,6 +26,12 @@ DownIcon::DownIcon(QWidget* parent)
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void DownIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
void DownIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
explicit DownIcon(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
||||
};
|
||||
|
@ -27,6 +27,13 @@ GoIcon::GoIcon(QWidget* parent)
|
||||
setHidden(true);
|
||||
}
|
||||
|
||||
void GoIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
|
||||
void GoIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
explicit GoIcon(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
|
||||
};
|
||||
|
@ -54,7 +54,8 @@ NavigationBar::NavigationBar(QupZilla* mainClass, QWidget* parent)
|
||||
{
|
||||
setObjectName("navigationbar");
|
||||
m_layout = new QHBoxLayout(this);
|
||||
m_layout->setContentsMargins(9, 3, 9, 3);
|
||||
m_layout->setMargin(3);
|
||||
m_layout->setSpacing(3);
|
||||
setLayout(m_layout);
|
||||
|
||||
m_buttonBack = new ToolButton(this);
|
||||
|
@ -32,21 +32,27 @@ SiteIcon::SiteIcon(LocationBar* parent)
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
}
|
||||
|
||||
void SiteIcon::contextMenuEvent(QContextMenuEvent* e)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
e->accept();
|
||||
}
|
||||
|
||||
void SiteIcon::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->buttons() & Qt::LeftButton) {
|
||||
m_dragStartPosition = mapFromGlobal(e->globalPos());
|
||||
}
|
||||
|
||||
ToolButton::mousePressEvent(e);
|
||||
|
||||
// Prevent propagating to LocationBar
|
||||
e->accept();
|
||||
|
||||
ToolButton::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void SiteIcon::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
if (!m_locationBar) {
|
||||
if (!m_locationBar || !(e->buttons() & Qt::LeftButton)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
explicit SiteIcon(LocationBar* parent);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* e);
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
void mouseMoveEvent(QMouseEvent* e);
|
||||
|
||||
|
@ -34,6 +34,19 @@
|
||||
#include <QWebFrame>
|
||||
#include <QClipboard>
|
||||
|
||||
WebSearchBar_Button::WebSearchBar_Button(QWidget* parent)
|
||||
: ClickableLabel(parent)
|
||||
{
|
||||
setObjectName("websearchbar-searchbutton");
|
||||
setCursor(QCursor(Qt::PointingHandCursor));
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
}
|
||||
|
||||
void WebSearchBar_Button::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
event->accept();
|
||||
}
|
||||
|
||||
WebSearchBar::WebSearchBar(QupZilla* mainClass, QWidget* parent)
|
||||
: LineEdit(parent)
|
||||
, p_QupZilla(mainClass)
|
||||
@ -42,10 +55,8 @@ WebSearchBar::WebSearchBar(QupZilla* mainClass, QWidget* parent)
|
||||
, m_clearAction(0)
|
||||
{
|
||||
setObjectName("websearchbar");
|
||||
m_buttonSearch = new ClickableLabel(this);
|
||||
m_buttonSearch->setObjectName("websearchbar-searchbutton");
|
||||
m_buttonSearch->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
m_buttonSearch->setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
m_buttonSearch = new WebSearchBar_Button(this);
|
||||
|
||||
m_boxSearchType = new ButtonWithMenu(this);
|
||||
m_boxSearchType->setObjectName("websearchbar-searchprovider-comobobox");
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "lineedit.h"
|
||||
#include "buttonwithmenu.h"
|
||||
#include "searchenginesmanager.h"
|
||||
#include "clickablelabel.h"
|
||||
|
||||
class QStringListModel;
|
||||
|
||||
@ -34,6 +35,15 @@ class SearchEnginesManager;
|
||||
class SearchEnginesDialog;
|
||||
class OpenSearchEngine;
|
||||
|
||||
class QT_QUPZILLA_EXPORT WebSearchBar_Button : public ClickableLabel
|
||||
{
|
||||
public:
|
||||
explicit WebSearchBar_Button(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT WebSearchBar : public LineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -76,7 +86,7 @@ private:
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
|
||||
ClickableLabel* m_buttonSearch;
|
||||
WebSearchBar_Button* m_buttonSearch;
|
||||
ButtonWithMenu* m_boxSearchType;
|
||||
SearchEnginesManager* m_searchManager;
|
||||
QWeakPointer<SearchEnginesDialog> m_searchDialog;
|
||||
|
@ -323,11 +323,11 @@ QNetworkReply* NetworkManager::createRequest(QNetworkAccessManager::Operation op
|
||||
QNetworkReply* reply = 0;
|
||||
|
||||
if (m_doNotTrack) {
|
||||
req.setRawHeader("DNT", "1");
|
||||
req.setRawHeader("DNT", QByteArray("1"));
|
||||
}
|
||||
|
||||
if (!m_sendReferer) {
|
||||
req.setRawHeader("Referer", "");
|
||||
req.setRawHeader("Referer", QByteArray());
|
||||
}
|
||||
|
||||
req.setRawHeader("Accept-Language", m_acceptLanguage);
|
||||
|
@ -159,15 +159,16 @@ void SearchEnginesManager::engineChangedImage()
|
||||
foreach(Engine e, m_allEngines) {
|
||||
if (e.name == engine->name() && e.url.contains(engine->searchUrl("%s").toString())
|
||||
&& !engine->image().isNull()) {
|
||||
e.icon = QIcon(QPixmap::fromImage(engine->image()));
|
||||
|
||||
m_allEngines.removeOne(e);
|
||||
m_allEngines.append(e);
|
||||
int index = m_allEngines.indexOf(e);
|
||||
if (index != -1) {
|
||||
m_allEngines[index].icon = QIcon(QPixmap::fromImage(engine->image()));
|
||||
|
||||
emit enginesChanged();
|
||||
emit enginesChanged();
|
||||
|
||||
delete engine;
|
||||
break;
|
||||
delete engine;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
35
src/lib/other/licenseviewer.cpp
Normal file
35
src/lib/other/licenseviewer.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 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 "licenseviewer.h"
|
||||
#include "globalfunctions.h"
|
||||
|
||||
LicenseViewer::LicenseViewer(QWidget* parent)
|
||||
: QTextBrowser()
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle(tr("License Viewer"));
|
||||
|
||||
resize(450, 500);
|
||||
|
||||
qz_centerWidgetToParent(this, parent);
|
||||
}
|
||||
|
||||
void LicenseViewer::setLicenseFile(const QString &fileName)
|
||||
{
|
||||
setText(qz_readAllFileContents(fileName));
|
||||
}
|
35
src/lib/other/licenseviewer.h
Normal file
35
src/lib/other/licenseviewer.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 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 LICENSEVIEWER_H
|
||||
#define LICENSEVIEWER_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QT_QUPZILLA_EXPORT LicenseViewer : public QTextBrowser
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LicenseViewer(QWidget* parent = 0);
|
||||
|
||||
void setLicenseFile(const QString &fileName);
|
||||
};
|
||||
|
||||
#endif // LICENSEVIEWER_H
|
@ -22,57 +22,86 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QWebFrame>
|
||||
#include <QTimer>
|
||||
#include <QMovie>
|
||||
#include <QtConcurrentRun>
|
||||
#include <QPushButton>
|
||||
|
||||
PageScreen::PageScreen(WebView* view, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::PageScreen)
|
||||
, m_view(view)
|
||||
, m_imageScaling(0)
|
||||
, m_horizontalScrollbarSize(0)
|
||||
, m_verticalScrollbarSize(0)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
ui->setupUi(this);
|
||||
|
||||
createPixmap();
|
||||
ui->label->setPixmap(m_pagePixmap);
|
||||
QMovie* mov = new QMovie(":html/loading.gif");
|
||||
ui->label->setMovie(mov);
|
||||
mov->start();
|
||||
|
||||
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
|
||||
m_pageTitle = m_view->title();
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(dialogAccepted()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close()));
|
||||
|
||||
QTimer::singleShot(200, this, SLOT(createThumbnail()));
|
||||
}
|
||||
|
||||
void PageScreen::buttonClicked(QAbstractButton* b)
|
||||
void PageScreen::dialogAccepted()
|
||||
{
|
||||
QString path;
|
||||
const QString &path = QFileDialog::getSaveFileName(this, tr("Save Page Screen..."),
|
||||
QDir::homePath() + "/" + QString("%1.png").arg(qz_filterCharsFromFilename(m_pageTitle)));
|
||||
|
||||
switch (ui->buttonBox->standardButton(b)) {
|
||||
case QDialogButtonBox::Cancel:
|
||||
close();
|
||||
break;
|
||||
if (!path.isEmpty()) {
|
||||
m_pageImage.save(path);
|
||||
|
||||
case QDialogButtonBox::Save:
|
||||
path = QFileDialog::getSaveFileName(this, tr("Save Page Screen..."), tr("screen.png"));
|
||||
if (!path.isEmpty()) {
|
||||
m_pagePixmap.save(path);
|
||||
close();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
QTimer::singleShot(0, this, SLOT(close()));
|
||||
}
|
||||
}
|
||||
|
||||
void PageScreen::createPixmap()
|
||||
void PageScreen::createThumbnail()
|
||||
{
|
||||
QWebPage* page = m_view->page();
|
||||
QSize originalSize = page->viewportSize();
|
||||
page->setViewportSize(page->mainFrame()->contentsSize());
|
||||
|
||||
QImage image(page->viewportSize(), QImage::Format_ARGB32);
|
||||
QPainter painter(&image);
|
||||
m_pageImage = QImage(page->viewportSize(), QImage::Format_ARGB32_Premultiplied);
|
||||
QPainter painter(&m_pageImage);
|
||||
page->mainFrame()->render(&painter);
|
||||
painter.end();
|
||||
|
||||
m_pagePixmap = QPixmap::fromImage(image);
|
||||
m_verticalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Vertical).width();
|
||||
m_horizontalScrollbarSize = page->mainFrame()->scrollBarGeometry(Qt::Horizontal).height();
|
||||
|
||||
page->setViewportSize(originalSize);
|
||||
|
||||
m_imageScaling = new QFutureWatcher<QImage>(this);
|
||||
connect(m_imageScaling, SIGNAL(finished()), SLOT(showImage()));
|
||||
|
||||
m_imageScaling->setFuture(QtConcurrent::run(this, &PageScreen::scaleImage));
|
||||
}
|
||||
|
||||
QImage PageScreen::scaleImage()
|
||||
{
|
||||
if (m_verticalScrollbarSize > 0 || m_horizontalScrollbarSize > 0) {
|
||||
QRect newRect = m_pageImage.rect();
|
||||
newRect.setWidth(newRect.width() - m_verticalScrollbarSize);
|
||||
newRect.setHeight(newRect.height() - m_horizontalScrollbarSize);
|
||||
|
||||
m_pageImage = m_pageImage.copy(newRect);
|
||||
}
|
||||
|
||||
return m_pageImage.scaledToWidth(450, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
void PageScreen::showImage()
|
||||
{
|
||||
delete ui->label->movie();
|
||||
|
||||
ui->label->setPixmap(QPixmap::fromImage(m_imageScaling->result()));
|
||||
}
|
||||
|
||||
PageScreen::~PageScreen()
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define PAGESCREEN_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFutureWatcher>
|
||||
|
||||
#include "qz_namespace.h"
|
||||
|
||||
@ -39,15 +40,25 @@ public:
|
||||
explicit PageScreen(WebView* view, QWidget* parent);
|
||||
~PageScreen();
|
||||
|
||||
QImage scaleImage();
|
||||
|
||||
private slots:
|
||||
void buttonClicked(QAbstractButton* b);
|
||||
void createThumbnail();
|
||||
void showImage();
|
||||
|
||||
void dialogAccepted();
|
||||
|
||||
private:
|
||||
void createPixmap();
|
||||
|
||||
Ui::PageScreen* ui;
|
||||
WebView* m_view;
|
||||
QPixmap m_pagePixmap;
|
||||
QImage m_pageImage;
|
||||
QString m_pageTitle;
|
||||
|
||||
QFutureWatcher<QImage>* m_imageScaling;
|
||||
int m_horizontalScrollbarSize;
|
||||
int m_verticalScrollbarSize;
|
||||
};
|
||||
|
||||
#endif // PAGESCREEN_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>425</height>
|
||||
<width>562</width>
|
||||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -18,7 +18,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
@ -28,12 +28,6 @@
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -42,11 +36,11 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>376</height>
|
||||
<width>562</width>
|
||||
<height>366</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -56,7 +50,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -67,10 +67,13 @@ public:
|
||||
|
||||
virtual void populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r) { Q_UNUSED(menu) Q_UNUSED(view) Q_UNUSED(r) }
|
||||
|
||||
virtual bool mouseDoubleClick(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
virtual bool mousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
virtual bool mouseRelease(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
virtual bool mouseMove(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
|
||||
virtual bool wheelEvent(const Qz::ObjectName &type, QObject* obj, QWheelEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
|
||||
virtual bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
virtual bool keyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event) { Q_UNUSED(type) Q_UNUSED(obj) Q_UNUSED(event) return false; }
|
||||
};
|
||||
|
@ -42,6 +42,12 @@ void PluginProxy::unloadPlugin(Plugins::Plugin* plugin)
|
||||
void PluginProxy::registerAppEventHandler(const PluginProxy::EventHandlerType &type, PluginInterface* obj)
|
||||
{
|
||||
switch (type) {
|
||||
case MouseDoubleClickHandler:
|
||||
if (!m_mouseDoubleClickHandlers.contains(obj)) {
|
||||
m_mouseDoubleClickHandlers.append(obj);
|
||||
}
|
||||
break;
|
||||
|
||||
case MousePressHandler:
|
||||
if (!m_mousePressHandlers.contains(obj)) {
|
||||
m_mousePressHandlers.append(obj);
|
||||
@ -72,6 +78,12 @@ void PluginProxy::registerAppEventHandler(const PluginProxy::EventHandlerType &t
|
||||
}
|
||||
break;
|
||||
|
||||
case WheelEventHandler:
|
||||
if (!m_wheelEventHandlers.contains(obj)) {
|
||||
m_wheelEventHandlers.append(obj);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning("PluginProxy::registerAppEventHandler registering unknown event handler type");
|
||||
break;
|
||||
@ -96,6 +108,19 @@ void PluginProxy::populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitT
|
||||
}
|
||||
}
|
||||
|
||||
bool PluginProxy::processMouseDoubleClick(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event)
|
||||
{
|
||||
bool accepted = false;
|
||||
|
||||
foreach(PluginInterface * iPlugin, m_mouseDoubleClickHandlers) {
|
||||
if (iPlugin->mouseDoubleClick(type, obj, event)) {
|
||||
accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return accepted;
|
||||
}
|
||||
|
||||
bool PluginProxy::processMousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event)
|
||||
{
|
||||
bool accepted = false;
|
||||
@ -135,6 +160,19 @@ bool PluginProxy::processMouseMove(const Qz::ObjectName &type, QObject* obj, QMo
|
||||
return accepted;
|
||||
}
|
||||
|
||||
bool PluginProxy::processWheelEvent(const Qz::ObjectName &type, QObject* obj, QWheelEvent* event)
|
||||
{
|
||||
bool accepted = false;
|
||||
|
||||
foreach(PluginInterface * iPlugin, m_wheelEventHandlers) {
|
||||
if (iPlugin->wheelEvent(type, obj, event)) {
|
||||
accepted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return accepted;
|
||||
}
|
||||
|
||||
bool PluginProxy::processKeyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event)
|
||||
{
|
||||
bool accepted = false;
|
||||
@ -161,3 +199,23 @@ bool PluginProxy::processKeyRelease(const Qz::ObjectName &type, QObject* obj, QK
|
||||
return accepted;
|
||||
}
|
||||
|
||||
void PluginProxy::emitWebViewCreated(WebView* view)
|
||||
{
|
||||
emit webViewCreated(view);
|
||||
}
|
||||
|
||||
void PluginProxy::emitWebViewDeleted(WebView* view)
|
||||
{
|
||||
emit webViewDeleted(view);
|
||||
}
|
||||
|
||||
void PluginProxy::emitMainWindowCreated(QupZilla* window)
|
||||
{
|
||||
emit mainWindowCreated(window);
|
||||
}
|
||||
|
||||
void PluginProxy::emitMainWindowDeleted(QupZilla* window)
|
||||
{
|
||||
emit mainWindowDeleted(window);
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,12 @@
|
||||
|
||||
class QT_QUPZILLA_EXPORT PluginProxy : public Plugins
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum EventHandlerType { MousePressHandler, MouseReleaseHandler, MouseMoveHandler, KeyPressHandler, KeyReleaseHandler };
|
||||
enum EventHandlerType { MouseDoubleClickHandler, MousePressHandler, MouseReleaseHandler,
|
||||
MouseMoveHandler, KeyPressHandler, KeyReleaseHandler,
|
||||
WheelEventHandler
|
||||
};
|
||||
|
||||
explicit PluginProxy();
|
||||
|
||||
@ -34,21 +38,39 @@ public:
|
||||
|
||||
void populateWebViewMenu(QMenu* menu, WebView* view, const QWebHitTestResult &r);
|
||||
|
||||
bool processMouseDoubleClick(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
|
||||
bool processMousePress(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
|
||||
bool processMouseRelease(const Qz::ObjectName &object, QObject* obj, QMouseEvent* event);
|
||||
bool processMouseMove(const Qz::ObjectName &object, QObject* obj, QMouseEvent* event);
|
||||
bool processMouseRelease(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
|
||||
bool processMouseMove(const Qz::ObjectName &type, QObject* obj, QMouseEvent* event);
|
||||
|
||||
bool processKeyPress(const Qz::ObjectName &object, QObject* obj, QKeyEvent* event);
|
||||
bool processKeyRelease(const Qz::ObjectName &object, QObject* obj, QKeyEvent* event);
|
||||
bool processWheelEvent(const Qz::ObjectName &type, QObject* obj, QWheelEvent* event);
|
||||
|
||||
bool processKeyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
||||
bool processKeyRelease(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
||||
|
||||
void emitWebViewCreated(WebView* view);
|
||||
void emitWebViewDeleted(WebView* view);
|
||||
|
||||
void emitMainWindowCreated(QupZilla* window);
|
||||
void emitMainWindowDeleted(QupZilla* window);
|
||||
|
||||
signals:
|
||||
void webViewCreated(WebView* view);
|
||||
void webViewDeleted(WebView* view);
|
||||
|
||||
void mainWindowCreated(QupZilla* window);
|
||||
void mainWindowDeleted(QupZilla* window);
|
||||
|
||||
private:
|
||||
QList<PluginInterface*> m_mouseDoubleClickHandlers;
|
||||
QList<PluginInterface*> m_mousePressHandlers;
|
||||
QList<PluginInterface*> m_mouseReleaseHandlers;
|
||||
QList<PluginInterface*> m_mouseMoveHandlers;
|
||||
|
||||
QList<PluginInterface*> m_wheelEventHandlers;
|
||||
|
||||
QList<PluginInterface*> m_keyPressHandlers;
|
||||
QList<PluginInterface*> m_keyReleaseHandlers;
|
||||
|
||||
};
|
||||
|
||||
#define QZ_REGISTER_EVENT_HANDLER(Type) mApp->plugins()->registerAppEventHandler(Type, this);
|
||||
|
@ -56,7 +56,7 @@ void SpeedDial::loadSettings()
|
||||
"url:\"http://www.qupzilla.com\"|title:\"QupZilla\";"
|
||||
"url:\"http://blog.qupzilla.com\"|title:\"QupZilla Blog\";"
|
||||
"url:\"https://github.com/nowrep/QupZilla\"|title:\"QupZilla GitHub\";"
|
||||
"url:\"http://facebook.com\"|title:\"Facebook\";";
|
||||
"url:\"https://facebook.com\"|title:\"Facebook\";";
|
||||
}
|
||||
changed(allPages);
|
||||
|
||||
|
@ -125,8 +125,7 @@ void PopupWebPage::checkBehaviour()
|
||||
TabbedWebView* view = p_QupZilla->weView(index);
|
||||
view->setWebPage(this);
|
||||
if (m_isLoading) {
|
||||
view->slotLoadStarted();
|
||||
view->loadingProgress(m_progress);
|
||||
view->fakePageLoading(m_progress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
* ============================================================ */
|
||||
#include "pluginlistdelegate.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QListWidget>
|
||||
#include <QTextLayout>
|
||||
#include <QTextDocument>
|
||||
@ -31,6 +32,20 @@ PluginListDelegate::PluginListDelegate(QListWidget* parent)
|
||||
|
||||
void PluginListDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
|
||||
{
|
||||
QPalette::ColorGroup cg = option.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
|
||||
|
||||
if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
|
||||
cg = QPalette::Inactive;
|
||||
}
|
||||
|
||||
if (option.state & QStyle::State_Selected) {
|
||||
painter->fillRect(rect, option.palette.brush(cg, QPalette::Highlight));
|
||||
painter->setPen(option.palette.color(cg, QPalette::HighlightedText));
|
||||
}
|
||||
else {
|
||||
painter->setPen(option.palette.color(cg, QPalette::Text));
|
||||
}
|
||||
|
||||
QTextDocument textDocument;
|
||||
textDocument.setHtml(text);
|
||||
|
||||
@ -42,27 +57,32 @@ void PluginListDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewIt
|
||||
|
||||
textLayout.beginLayout();
|
||||
qreal height = 0;
|
||||
while (1) {
|
||||
QTextLine line = textLayout.createLine();
|
||||
if (!line.isValid()) {
|
||||
break;
|
||||
}
|
||||
QTextLine line = textLayout.createLine();
|
||||
|
||||
while (line.isValid()) {
|
||||
line.setLineWidth(textRect.width());
|
||||
height += 3;
|
||||
line.setPosition(QPoint(0, height));
|
||||
height += line.height();
|
||||
}
|
||||
textLayout.endLayout();
|
||||
|
||||
line = textLayout.createLine();
|
||||
}
|
||||
|
||||
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);
|
||||
Q_UNUSED(index)
|
||||
|
||||
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0) + 1;
|
||||
|
||||
QSize size;
|
||||
size.setWidth(m_listWidget->width() - 10);
|
||||
|
||||
// ( height of font * 3 = 3 lines ) + ( text margins ) + ( 2 free lines = every line is 3px )
|
||||
size.setHeight((option.fontMetrics.height() * 3) + (textMargin * 2) + (2 * 3));
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ 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));
|
||||
ui->list->setItemDelegate(new PluginListDelegate(ui->list));
|
||||
|
||||
//WebKit Plugins
|
||||
connect(ui->add, SIGNAL(clicked()), this, SLOT(addWhitelist()));
|
||||
@ -154,7 +154,7 @@ void PluginsList::refresh()
|
||||
PluginSpec spec = plugin.pluginSpec;
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(ui->list);
|
||||
QString pluginInfo = QString("<b>%1</b> %2 (%3)<br/>%4<br/>%5").arg(spec.name, spec.version, spec.author, spec.info, spec.description);
|
||||
QString pluginInfo = QString("<b>%1</b> %2 (%3)<br/>\n%4<br/>\n%5\n").arg(spec.name, spec.version, spec.author, spec.info, spec.description);
|
||||
item->setText(pluginInfo);
|
||||
|
||||
|
||||
|
@ -146,7 +146,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
|
||||
startProfileIndexChanged(ui->startProfile->currentText());
|
||||
|
||||
//APPEREANCE
|
||||
m_themesManager = new ThemeManager(ui->themesWidget);
|
||||
m_themesManager = new ThemeManager(ui->themesWidget, this);
|
||||
settings.beginGroup("Browser-View-Settings");
|
||||
ui->showStatusbar->setChecked(settings.value("showStatusBar", true).toBool());
|
||||
ui->showBookmarksToolbar->setChecked(p_QupZilla->bookmarksToolbar()->isVisible());
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "mainapplication.h"
|
||||
#include "globalfunctions.h"
|
||||
#include "settings.h"
|
||||
#include "licenseviewer.h"
|
||||
#include "preferences.h"
|
||||
|
||||
#include <QTextBrowser>
|
||||
#include <QDir>
|
||||
@ -30,9 +32,10 @@
|
||||
#define DEFAULT_THEME_NAME "linux"
|
||||
#endif
|
||||
|
||||
ThemeManager::ThemeManager(QWidget* parent)
|
||||
ThemeManager::ThemeManager(QWidget* parent, Preferences* preferences)
|
||||
: QWidget()
|
||||
, ui(new Ui::ThemeManager)
|
||||
, m_preferences(preferences)
|
||||
{
|
||||
ui->setupUi(parent);
|
||||
ui->license->hide();
|
||||
@ -78,14 +81,9 @@ void ThemeManager::showLicense()
|
||||
|
||||
Theme currentTheme = m_themeHash[currentItem->data(Qt::UserRole).toString()];
|
||||
|
||||
QTextBrowser* b = new QTextBrowser();
|
||||
b->setAttribute(Qt::WA_DeleteOnClose);
|
||||
b->setWindowTitle(tr("License Viewer"));
|
||||
// b->move(mapToGlobal(parent()->pos()));
|
||||
b->resize(450, 500);
|
||||
b->setText(currentTheme.license);
|
||||
qz_centerWidgetOnScreen(b);
|
||||
b->show();
|
||||
LicenseViewer* v = new LicenseViewer(m_preferences);
|
||||
v->setText(currentTheme.license);
|
||||
v->show();
|
||||
}
|
||||
|
||||
void ThemeManager::currentChanged()
|
||||
|
@ -30,12 +30,14 @@ namespace Ui
|
||||
class ThemeManager;
|
||||
}
|
||||
|
||||
class Preferences;
|
||||
|
||||
class QT_QUPZILLA_EXPORT ThemeManager : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ThemeManager(QWidget* parent);
|
||||
explicit ThemeManager(QWidget* parent, Preferences* preferences);
|
||||
~ThemeManager();
|
||||
|
||||
void save();
|
||||
@ -58,6 +60,8 @@ private:
|
||||
Theme parseTheme(const QString &name);
|
||||
|
||||
Ui::ThemeManager* ui;
|
||||
Preferences* m_preferences;
|
||||
|
||||
QString m_activeTheme;
|
||||
QHash<QString, Theme> m_themeHash;
|
||||
};
|
||||
|
@ -28,6 +28,12 @@ RssIcon::RssIcon(QWidget* parent)
|
||||
setVisible(false);
|
||||
}
|
||||
|
||||
void RssIcon::contextMenuEvent(QContextMenuEvent* ev)
|
||||
{
|
||||
// Prevent propagating to LocationBar
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
void RssIcon::mousePressEvent(QMouseEvent* ev)
|
||||
{
|
||||
ClickableLabel::mousePressEvent(ev);
|
||||
|
@ -28,6 +28,7 @@ public:
|
||||
explicit RssIcon(QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
void contextMenuEvent(QContextMenuEvent* ev);
|
||||
void mousePressEvent(QMouseEvent* ev);
|
||||
};
|
||||
|
||||
|
@ -207,7 +207,8 @@ QString qz_getFileNameFromUrl(const QUrl &url)
|
||||
fileName = fileName.mid(pos);
|
||||
fileName.remove("/");
|
||||
}
|
||||
return fileName;
|
||||
|
||||
return qz_filterCharsFromFilename(fileName);
|
||||
}
|
||||
|
||||
QString qz_filterCharsFromFilename(const QString &name)
|
||||
|
@ -33,6 +33,8 @@ void IconFetcher::fetchIcon(const QUrl &url)
|
||||
|
||||
FollowRedirectReply* reply = new FollowRedirectReply(url, m_manager);
|
||||
connect(reply, SIGNAL(finished()), this, SLOT(pageDownloaded()));
|
||||
|
||||
m_url = url;
|
||||
}
|
||||
|
||||
void IconFetcher::pageDownloaded()
|
||||
@ -95,9 +97,8 @@ void IconFetcher::iconDownloaded()
|
||||
if (!response.isEmpty()) {
|
||||
QImage image;
|
||||
image.loadFromData(response);
|
||||
QIcon icon = QIcon(QPixmap::fromImage(image));
|
||||
if (!icon.isNull()) {
|
||||
emit iconFetched(icon);
|
||||
if (!image.isNull()) {
|
||||
emit iconFetched(image);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QIcon>
|
||||
#include <QVariant>
|
||||
#include <QUrl>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QUrl;
|
||||
@ -36,8 +38,13 @@ public:
|
||||
void setNetworkAccessManager(QNetworkAccessManager* manager) { m_manager = manager; }
|
||||
void fetchIcon(const QUrl &url);
|
||||
|
||||
void setData(const QVariant &data) { m_data = data; }
|
||||
QVariant data() { return m_data; }
|
||||
|
||||
QUrl url() { return m_url; }
|
||||
|
||||
signals:
|
||||
void iconFetched(QIcon);
|
||||
void iconFetched(QImage);
|
||||
void finished();
|
||||
|
||||
public slots:
|
||||
@ -49,6 +56,9 @@ private slots:
|
||||
private:
|
||||
QNetworkAccessManager* m_manager;
|
||||
|
||||
QVariant m_data;
|
||||
QUrl m_url;
|
||||
|
||||
};
|
||||
|
||||
#endif // ICONFETCHER_H
|
||||
|
@ -118,7 +118,7 @@ void PageThumbnailer::createThumbnail(bool status)
|
||||
|
||||
m_title = m_page->mainFrame()->title();
|
||||
|
||||
QImage image(m_page->viewportSize(), QImage::Format_ARGB32);
|
||||
QImage image(m_page->viewportSize(), QImage::Format_ARGB32_Premultiplied);
|
||||
QPainter painter(&image);
|
||||
m_page->mainFrame()->render(&painter);
|
||||
painter.end();
|
||||
|
@ -138,9 +138,12 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent)
|
||||
|
||||
connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
|
||||
connect(ui->secDetailsButton, SIGNAL(clicked()), this, SLOT(securityDetailsClicked()));
|
||||
connect(ui->saveButton, SIGNAL(clicked(QAbstractButton*)), this, SLOT(downloadImage()));
|
||||
|
||||
connect(ui->treeImages, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(showImagePreview(QTreeWidgetItem*)));
|
||||
ui->treeImages->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(ui->treeImages, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(imagesCustomContextMenuRequested(const QPoint &)));
|
||||
|
||||
ui->treeImages->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
void SiteInfo::imagesCustomContextMenuRequested(const QPoint &p)
|
||||
@ -154,7 +157,7 @@ void SiteInfo::imagesCustomContextMenuRequested(const QPoint &p)
|
||||
menu.addAction(QIcon::fromTheme("edit-copy"), tr("Copy Image Location"), this, SLOT(copyActionData()))->setData(item->text(1));
|
||||
menu.addAction(tr("Copy Image Name"), this, SLOT(copyActionData()))->setData(item->text(0));
|
||||
menu.addSeparator();
|
||||
menu.addAction(QIcon::fromTheme("document-save"), tr("Save Image to Disk"), this, SLOT(downloadImage()))->setData(ui->treeImages->indexOfTopLevelItem(item));
|
||||
menu.addAction(QIcon::fromTheme("document-save"), tr("Save Image to Disk"), this, SLOT(downloadImage()));
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
@ -167,28 +170,26 @@ void SiteInfo::copyActionData()
|
||||
|
||||
void SiteInfo::downloadImage()
|
||||
{
|
||||
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
||||
QTreeWidgetItem* item = ui->treeImages->topLevelItem(action->data().toInt());
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
QTreeWidgetItem* item = ui->treeImages->currentItem();
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_activePixmap.isNull()) {
|
||||
QMessageBox::warning(this, tr("Error!"), tr("This preview is not available!"));
|
||||
return;
|
||||
}
|
||||
if (m_activePixmap.isNull()) {
|
||||
QMessageBox::warning(this, tr("Error!"), tr("This preview is not available!"));
|
||||
return;
|
||||
}
|
||||
|
||||
QString imageFileName = qz_getFileNameFromUrl(QUrl(item->text(1)));
|
||||
QString imageFileName = qz_getFileNameFromUrl(QUrl(item->text(1)));
|
||||
|
||||
QString filePath = QFileDialog::getSaveFileName(this, tr("Save image..."), QDir::homePath() + "/" + imageFileName);
|
||||
if (filePath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QString filePath = QFileDialog::getSaveFileName(this, tr("Save image..."), QDir::homePath() + "/" + imageFileName);
|
||||
if (filePath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_activePixmap.save(filePath)) {
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Cannot write to file!"));
|
||||
return;
|
||||
}
|
||||
if (!m_activePixmap.save(filePath)) {
|
||||
QMessageBox::critical(this, tr("Error!"), tr("Cannot write to file!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,40 +7,14 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>590</width>
|
||||
<height>455</height>
|
||||
<height>492</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Site Info</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="6" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="SqueezeLabelV2" name="heading">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>550</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@ -101,7 +75,23 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="1" column="0">
|
||||
<widget class="SqueezeLabelV2" name="heading">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>550</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
@ -279,35 +269,48 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="QTreeWidget" name="treeImages">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerMinimumSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Image</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Image address</string>
|
||||
</property>
|
||||
</column>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="treeImages">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="itemsExpandable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="headerMinimumSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Image</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Image address</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="saveButton">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Save</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -371,6 +374,16 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "toolbutton.h"
|
||||
#include "settings.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "mainapplication.h"
|
||||
#include "pluginproxy.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QApplication>
|
||||
@ -57,6 +59,8 @@ TabBar::TabBar(QupZilla* mainClass, TabWidget* tabWidget)
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
loadSettings();
|
||||
|
||||
setAcceptDrops(true);
|
||||
|
||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &)));
|
||||
connect(m_tabWidget, SIGNAL(pinnedTabClosed()), this, SLOT(pinnedTabClosed()));
|
||||
connect(m_tabWidget, SIGNAL(pinnedTabAdded()), this, SLOT(pinnedTabAdded()));
|
||||
@ -328,8 +332,26 @@ int TabBar::normalTabsCount()
|
||||
return count() - m_pinnedTabsCount;
|
||||
}
|
||||
|
||||
void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
{
|
||||
if (mApp->plugins()->processMouseDoubleClick(Qz::ON_TabBar, this, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->button() == Qt::LeftButton && tabAt(event->pos()) == -1) {
|
||||
m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
|
||||
return;
|
||||
}
|
||||
|
||||
QTabBar::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
if (mApp->plugins()->processMousePress(Qz::ON_TabBar, this, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->buttons() & Qt::LeftButton && tabAt(event->pos()) != -1) {
|
||||
m_dragStartPosition = mapFromGlobal(event->globalPos());
|
||||
}
|
||||
@ -342,6 +364,10 @@ void TabBar::mousePressEvent(QMouseEvent* event)
|
||||
|
||||
void TabBar::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
if (mApp->plugins()->processMouseMove(Qz::ON_TabBar, this, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_dragStartPosition.isNull() && m_tabWidget->buttonAddTab()->isVisible()) {
|
||||
int manhattanLength = (event->pos() - m_dragStartPosition).manhattanLength();
|
||||
if (manhattanLength > QApplication::startDragDistance()) {
|
||||
@ -352,18 +378,12 @@ void TabBar::mouseMoveEvent(QMouseEvent* event)
|
||||
QTabBar::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::mouseDoubleClickEvent(QMouseEvent* event)
|
||||
void TabBar::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton && tabAt(event->pos()) == -1) {
|
||||
m_tabWidget->addView(QUrl(), Qz::NT_SelectedTabAtTheEnd, true);
|
||||
if (mApp->plugins()->processMouseRelease(Qz::ON_TabBar, this, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTabBar::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (m_tabWidget->buttonAddTab()->isHidden()) {
|
||||
QTimer::singleShot(500, m_tabWidget->buttonAddTab(), SLOT(show()));
|
||||
}
|
||||
@ -386,6 +406,38 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event)
|
||||
QTabBar::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (mime->hasUrls()) {
|
||||
event->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
|
||||
QTabBar::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
void TabBar::dropEvent(QDropEvent* event)
|
||||
{
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (!mime->hasUrls()) {
|
||||
QTabBar::dropEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
int index = tabAt(event->pos());
|
||||
if (index == -1) {
|
||||
foreach(const QUrl & url, mime->urls()) {
|
||||
m_tabWidget->addView(url, Qz::NT_SelectedTabAtTheEnd);
|
||||
}
|
||||
}
|
||||
else {
|
||||
p_QupZilla->weView(index)->load(mime->urls().first());
|
||||
}
|
||||
}
|
||||
|
||||
void TabBar::disconnectObjects()
|
||||
{
|
||||
disconnect(this);
|
||||
|
@ -79,10 +79,14 @@ private slots:
|
||||
void closeCurrentTab();
|
||||
|
||||
private:
|
||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
QSize tabSizeHint(int index) const;
|
||||
// void tabInserted(int index);
|
||||
|
||||
|
@ -374,6 +374,7 @@ void TabbedWebView::mouseMoveEvent(QMouseEvent* event)
|
||||
p_QupZilla->showNavigationWithFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
WebView::mouseMoveEvent(event);
|
||||
}
|
||||
|
||||
@ -381,6 +382,15 @@ void TabbedWebView::disconnectObjects()
|
||||
{
|
||||
disconnect(this);
|
||||
disconnect(p_QupZilla->statusBar());
|
||||
|
||||
WebView::disconnectObjects();
|
||||
}
|
||||
|
||||
void TabbedWebView::fakePageLoading(int progress)
|
||||
{
|
||||
WebView::slotLoadStarted();
|
||||
slotLoadStarted();
|
||||
loadingProgress(progress);
|
||||
}
|
||||
|
||||
TabbedWebView::~TabbedWebView()
|
||||
|
@ -50,9 +50,10 @@ public:
|
||||
bool hasRss() { return m_hasRss; }
|
||||
|
||||
QWidget* overlayForJsAlert();
|
||||
|
||||
void disconnectObjects();
|
||||
|
||||
void fakePageLoading(int progress);
|
||||
|
||||
signals:
|
||||
void wantsCloseTab(int);
|
||||
void ipChanged(QString);
|
||||
|
@ -15,11 +15,11 @@
|
||||
* 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 "tabwidget.h"
|
||||
#include "tabbar.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "webpage.h"
|
||||
#include "qupzilla.h"
|
||||
#include "tabwidget.h"
|
||||
#include "tabbar.h"
|
||||
#include "iconprovider.h"
|
||||
#include "mainapplication.h"
|
||||
#include "webtab.h"
|
||||
@ -27,7 +27,6 @@
|
||||
#include "closedtabsmanager.h"
|
||||
#include "progressbar.h"
|
||||
#include "navigationbar.h"
|
||||
#include "toolbutton.h"
|
||||
#include "locationbar.h"
|
||||
#include "websearchbar.h"
|
||||
#include "settings.h"
|
||||
@ -37,71 +36,45 @@
|
||||
#include <QMenu>
|
||||
#include <QStackedWidget>
|
||||
#include <QWebHistory>
|
||||
#include <QFile>
|
||||
|
||||
class QT_QUPZILLA_EXPORT NewTabButton : public QToolButton
|
||||
AddTabButton::AddTabButton(TabWidget* tabWidget, TabBar* tabBar)
|
||||
: ToolButton(tabWidget)
|
||||
, m_tabBar(tabBar)
|
||||
, m_tabWidget(tabWidget)
|
||||
{
|
||||
public:
|
||||
explicit NewTabButton(QWidget* parent) : QToolButton(parent) {
|
||||
#ifndef Q_WS_WIN
|
||||
setIcon(QIcon::fromTheme("list-add"));
|
||||
setIconSize(QSize(16, 16));
|
||||
setAutoRaise(true);
|
||||
#endif
|
||||
}
|
||||
QSize sizeHint() const {
|
||||
QSize siz = QToolButton::sizeHint();
|
||||
siz.setWidth(26);
|
||||
return siz;
|
||||
}
|
||||
setObjectName("tabwidget-button-addtab");
|
||||
setAutoRaise(true);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setAcceptDrops(true);
|
||||
setToolTip(TabWidget::tr("New Tab"));
|
||||
}
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
private:
|
||||
void paintEvent(QPaintEvent*) {
|
||||
QPainter p(this);
|
||||
QStyleOptionTabV3 opt;
|
||||
opt.init(this);
|
||||
style()->drawControl(QStyle::CE_TabBarTab, &opt, &p, this);
|
||||
|
||||
QPixmap pix(":/icons/other/list-add.png");
|
||||
QRect r = this->rect();
|
||||
r.setHeight(r.height() + 3);
|
||||
r.setWidth(r.width() + 3);
|
||||
style()->drawItemPixmap(&p, r, Qt::AlignCenter, pix);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT TabListButton : public QToolButton
|
||||
void AddTabButton::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
public:
|
||||
explicit TabListButton(QWidget* parent) : QToolButton(parent) {
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (mime->hasUrls()) {
|
||||
event->acceptProposedAction();
|
||||
return;
|
||||
}
|
||||
|
||||
QSize sizeHint() const {
|
||||
QSize siz = QToolButton::sizeHint();
|
||||
siz.setWidth(20);
|
||||
return siz;
|
||||
ToolButton::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
void AddTabButton::dropEvent(QDropEvent* event)
|
||||
{
|
||||
const QMimeData* mime = event->mimeData();
|
||||
|
||||
if (!mime->hasUrls()) {
|
||||
ToolButton::dropEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
void paintEvent(QPaintEvent*) {
|
||||
QPainter p(this);
|
||||
QStyleOptionToolButton opt;
|
||||
opt.init(this);
|
||||
if (isDown()) {
|
||||
opt.state |= QStyle::State_On;
|
||||
}
|
||||
if (opt.state & QStyle::State_MouseOver) {
|
||||
opt.activeSubControls = QStyle::SC_ToolButton;
|
||||
}
|
||||
if (!isChecked() && !isDown()) {
|
||||
opt.state |= QStyle::State_Raised;
|
||||
}
|
||||
opt.state |= QStyle::State_AutoRaise;
|
||||
|
||||
style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
|
||||
foreach(const QUrl & url, mime->urls()) {
|
||||
m_tabWidget->addView(url, Qz::NT_SelectedTabAtTheEnd);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent)
|
||||
: QTabWidget(parent)
|
||||
@ -142,11 +115,7 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent)
|
||||
m_buttonListTabs->setAutoRaise(true);
|
||||
m_buttonListTabs->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
m_buttonAddTab = new ToolButton(this);
|
||||
m_buttonAddTab->setObjectName("tabwidget-button-addtab");
|
||||
m_buttonAddTab->setAutoRaise(true);
|
||||
m_buttonAddTab->setToolTip(tr("New Tab"));
|
||||
m_buttonAddTab->setFocusPolicy(Qt::NoFocus);
|
||||
m_buttonAddTab = new AddTabButton(this, m_tabBar);
|
||||
|
||||
connect(m_buttonAddTab, SIGNAL(clicked()), p_QupZilla, SLOT(addTab()));
|
||||
connect(m_menuTabs, SIGNAL(aboutToShow()), this, SLOT(aboutToShowClosedTabsMenu()));
|
||||
@ -755,8 +724,8 @@ bool TabWidget::restoreState(const QByteArray &state)
|
||||
void TabWidget::disconnectObjects()
|
||||
{
|
||||
disconnect(this);
|
||||
disconnect(p_QupZilla);
|
||||
disconnect(mApp);
|
||||
disconnect(p_QupZilla);
|
||||
disconnect(p_QupZilla->ipLabel());
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QTabWidget>
|
||||
#include <QUrl>
|
||||
|
||||
#include "toolbutton.h"
|
||||
#include "qz_namespace.h"
|
||||
|
||||
class QStackedWidget;
|
||||
@ -29,11 +30,22 @@ class QMenu;
|
||||
class QupZilla;
|
||||
class TabbedWebView;
|
||||
class TabBar;
|
||||
class TabWidget;
|
||||
class WebTab;
|
||||
class TabListButton;
|
||||
class NewTabButton;
|
||||
class ClosedTabsManager;
|
||||
class ToolButton;
|
||||
|
||||
class QT_QUPZILLA_EXPORT AddTabButton : public ToolButton
|
||||
{
|
||||
public:
|
||||
explicit AddTabButton(TabWidget* tabWidget, TabBar* tabBar);
|
||||
|
||||
private:
|
||||
void dragEnterEvent(QDragEnterEvent* event);
|
||||
void dropEvent(QDropEvent* event);
|
||||
|
||||
TabBar* m_tabBar;
|
||||
TabWidget* m_tabWidget;
|
||||
};
|
||||
|
||||
class QT_QUPZILLA_EXPORT TabWidget : public QTabWidget
|
||||
{
|
||||
@ -56,7 +68,7 @@ public:
|
||||
QList<WebTab*> allTabs(bool withPinned = true);
|
||||
QStackedWidget* locationBars() { return m_locationBars; }
|
||||
ToolButton* buttonListTabs() { return m_buttonListTabs; }
|
||||
ToolButton* buttonAddTab() { return m_buttonAddTab; }
|
||||
AddTabButton* buttonAddTab() { return m_buttonAddTab; }
|
||||
|
||||
void createKeyPressEvent(QKeyEvent* event);
|
||||
void showTabBar();
|
||||
@ -114,7 +126,7 @@ private:
|
||||
|
||||
QMenu* m_menuTabs;
|
||||
ToolButton* m_buttonListTabs;
|
||||
ToolButton* m_buttonAddTab;
|
||||
AddTabButton* m_buttonAddTab;
|
||||
ClosedTabsManager* m_closedTabsManager;
|
||||
|
||||
QStackedWidget* m_locationBars;
|
||||
|
@ -60,6 +60,8 @@ WebView::WebView(QWidget* parent)
|
||||
m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300;
|
||||
|
||||
qApp->installEventFilter(this);
|
||||
|
||||
mApp->plugins()->emitWebViewCreated(this);
|
||||
}
|
||||
|
||||
QIcon WebView::icon() const
|
||||
@ -778,6 +780,10 @@ void WebView::muteMedia()
|
||||
|
||||
void WebView::wheelEvent(QWheelEvent* event)
|
||||
{
|
||||
if (mApp->plugins()->processWheelEvent(Qz::ON_WebView, this, event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->modifiers() & Qt::ControlModifier) {
|
||||
int numDegrees = event->delta() / 8;
|
||||
int numSteps = numDegrees / 15;
|
||||
@ -1019,3 +1025,9 @@ bool WebView::eventFilter(QObject* obj, QEvent* event)
|
||||
return QWebView::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void WebView::disconnectObjects()
|
||||
{
|
||||
disconnect(this);
|
||||
|
||||
mApp->plugins()->emitWebViewDeleted(this);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
virtual QWidget* overlayForJsAlert() = 0;
|
||||
virtual void disconnectObjects();
|
||||
|
||||
static bool isUrlValid(const QUrl &url);
|
||||
static QUrl guessUrlFromString(const QString &string);
|
||||
|
@ -16,8 +16,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QTextCodec>
|
||||
#include <iostream>
|
||||
|
||||
#include "commandlineoptions.h"
|
||||
|
23
src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro
Normal file
23
src/plugins/AccessKeysNavigation/AccessKeysNavigation.pro
Normal file
@ -0,0 +1,23 @@
|
||||
QT += webkit
|
||||
TARGET = AccessKeysNavigation
|
||||
|
||||
SOURCES = \
|
||||
akn_plugin.cpp \
|
||||
akn_handler.cpp \
|
||||
akn_settings.cpp
|
||||
|
||||
HEADERS = \
|
||||
akn_plugin.h \
|
||||
akn_handler.h \
|
||||
akn_settings.h
|
||||
|
||||
FORMS += \
|
||||
akn_settings.ui
|
||||
|
||||
RESOURCES = akn_res.qrc
|
||||
|
||||
TRANSLATIONS = translations/cs_CZ.ts \
|
||||
translations/sr_BA.ts \
|
||||
translations/sr_RS.ts \
|
||||
|
||||
include(../../plugins.pri)
|
337
src/plugins/AccessKeysNavigation/akn_handler.cpp
Normal file
337
src/plugins/AccessKeysNavigation/akn_handler.cpp
Normal file
@ -0,0 +1,337 @@
|
||||
/* ============================================================
|
||||
* Access Keys Navigation plugin for QupZilla
|
||||
* Copyright (C) 2012 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/>.
|
||||
* ============================================================ */
|
||||
/*
|
||||
* Copyright 2008-2009 Benjamin C. Meyer <ben@meyerhome.net>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "akn_handler.h"
|
||||
#include "webview.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
#include <QWebPage>
|
||||
#include <QWebFrame>
|
||||
#include <QLabel>
|
||||
#include <QTimer>
|
||||
#include <QToolTip>
|
||||
|
||||
Qt::Key keyFromCode(int code)
|
||||
{
|
||||
switch (code) {
|
||||
case 0:
|
||||
return Qt::Key_Control;
|
||||
|
||||
case 1:
|
||||
return Qt::Key_Alt;
|
||||
|
||||
case 2:
|
||||
return Qt::Key_Shift;
|
||||
|
||||
default:
|
||||
// Using default shortcut
|
||||
return Qt::Key_Control;
|
||||
}
|
||||
}
|
||||
|
||||
AKN_Handler::AKN_Handler(const QString &sPath, QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_view(0)
|
||||
, m_settingsPath(sPath)
|
||||
{
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
QString AKN_Handler::settingsPath()
|
||||
{
|
||||
return m_settingsPath;
|
||||
}
|
||||
|
||||
void AKN_Handler::loadSettings()
|
||||
{
|
||||
QSettings settings(m_settingsPath, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup("AccessKeysNavigation");
|
||||
m_key = keyFromCode(settings.value("Key", 0).toInt());
|
||||
m_isDoublePress = settings.value("DoublePress", true).toBool();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
bool AKN_Handler::handleKeyPress(QObject* obj, QKeyEvent* event)
|
||||
{
|
||||
WebView* view = qobject_cast<WebView*>(obj);
|
||||
if (!view) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_accessKeysVisible) {
|
||||
handleAccessKey(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (event->key() != m_key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_view = view;
|
||||
|
||||
if (!m_isDoublePress) {
|
||||
triggerShowAccessKeys();
|
||||
}
|
||||
else {
|
||||
if (!m_lastKeyPressTime.isValid()) {
|
||||
// It is the first press of our button
|
||||
m_lastKeyPressTime = QTime::currentTime();
|
||||
}
|
||||
else {
|
||||
// It is the second press of our button
|
||||
if (QTime(m_lastKeyPressTime).addMSecs(500) >= QTime::currentTime()) {
|
||||
triggerShowAccessKeys();
|
||||
}
|
||||
else {
|
||||
m_lastKeyPressTime = QTime::currentTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AKN_Handler::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (obj != m_view) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::Resize:
|
||||
case QEvent::FocusOut:
|
||||
case QEvent::Wheel:
|
||||
hideAccessKeys();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AKN_Handler::triggerShowAccessKeys()
|
||||
{
|
||||
if (m_accessKeysVisible) {
|
||||
hideAccessKeys();
|
||||
}
|
||||
else {
|
||||
QTimer::singleShot(0, this, SLOT(showAccessKeys()));
|
||||
}
|
||||
}
|
||||
|
||||
void AKN_Handler::handleAccessKey(QKeyEvent* event)
|
||||
{
|
||||
if (event->key() == m_key) {
|
||||
hideAccessKeys();
|
||||
return;
|
||||
}
|
||||
|
||||
QString text = event->text();
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
QChar key = text.at(0);
|
||||
|
||||
if (m_accessKeyNodes.contains(key)) {
|
||||
QWebElement element = m_accessKeyNodes[key];
|
||||
QPoint p = element.geometry().center();
|
||||
QWebFrame* frame = element.webFrame();
|
||||
|
||||
if (!frame) {
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
p -= frame->scrollPosition();
|
||||
frame = frame->parentFrame();
|
||||
}
|
||||
while (frame && frame != m_view->page()->mainFrame());
|
||||
|
||||
QMouseEvent pevent(QEvent::MouseButtonPress, p, Qt::LeftButton, 0, 0);
|
||||
qApp->sendEvent(m_view, &pevent);
|
||||
|
||||
QMouseEvent revent(QEvent::MouseButtonRelease, p, Qt::LeftButton, 0, 0);
|
||||
qApp->sendEvent(m_view, &revent);
|
||||
|
||||
hideAccessKeys();
|
||||
}
|
||||
}
|
||||
|
||||
void AKN_Handler::showAccessKeys()
|
||||
{
|
||||
if (!m_view) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWebPage* page = m_view->page();
|
||||
|
||||
// Install event filter and connect loadStarted
|
||||
m_accessKeysVisible = true;
|
||||
qApp->installEventFilter(this);
|
||||
connect(m_view, SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
|
||||
|
||||
QStringList supportedElement;
|
||||
supportedElement << QLatin1String("input")
|
||||
<< QLatin1String("a")
|
||||
<< QLatin1String("area")
|
||||
<< QLatin1String("button")
|
||||
<< QLatin1String("label")
|
||||
<< QLatin1String("legend")
|
||||
<< QLatin1String("textarea");
|
||||
|
||||
QList<QChar> unusedKeys;
|
||||
for (char c = 'A'; c <= 'Z'; ++c) {
|
||||
unusedKeys << QLatin1Char(c);
|
||||
}
|
||||
for (char c = '0'; c <= '9'; ++c) {
|
||||
unusedKeys << QLatin1Char(c);
|
||||
}
|
||||
for (char c = 'a'; c <= 'z'; ++c) {
|
||||
unusedKeys << QLatin1Char(c);
|
||||
}
|
||||
|
||||
QRect viewport = QRect(page->mainFrame()->scrollPosition(), page->viewportSize());
|
||||
// Priority first goes to elements with accesskey attributes
|
||||
QList<QWebElement> alreadyLabeled;
|
||||
foreach(const QString & elementType, supportedElement) {
|
||||
QList<QWebElement> result = page->mainFrame()->findAllElements(elementType).toList();
|
||||
foreach(const QWebElement & element, result) {
|
||||
const QRect geometry = element.geometry();
|
||||
if (geometry.size().isEmpty()
|
||||
|| !viewport.contains(geometry.topLeft())) {
|
||||
continue;
|
||||
}
|
||||
QString accessKeyAttribute = element.attribute(QLatin1String("accesskey")).toUpper();
|
||||
if (accessKeyAttribute.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
QChar accessKey;
|
||||
for (int i = 0; i < accessKeyAttribute.count(); i += 2) {
|
||||
const QChar &possibleAccessKey = accessKeyAttribute[i];
|
||||
if (unusedKeys.contains(possibleAccessKey)) {
|
||||
accessKey = possibleAccessKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (accessKey.isNull()) {
|
||||
continue;
|
||||
}
|
||||
unusedKeys.removeOne(accessKey);
|
||||
makeAccessKeyLabel(accessKey, element);
|
||||
alreadyLabeled.append(element);
|
||||
}
|
||||
}
|
||||
|
||||
// Pick an access key first from the letters in the text and then from the
|
||||
// list of unused access keys
|
||||
foreach(const QString & elementType, supportedElement) {
|
||||
QWebElementCollection result = page->mainFrame()->findAllElements(elementType);
|
||||
foreach(const QWebElement & element, result) {
|
||||
const QRect geometry = element.geometry();
|
||||
if (unusedKeys.isEmpty()
|
||||
|| alreadyLabeled.contains(element)
|
||||
|| geometry.size().isEmpty()
|
||||
|| !viewport.contains(geometry.topLeft())) {
|
||||
continue;
|
||||
}
|
||||
QChar accessKey;
|
||||
QString text = element.toPlainText().toUpper();
|
||||
for (int i = 0; i < text.count(); ++i) {
|
||||
const QChar &c = text.at(i);
|
||||
if (unusedKeys.contains(c)) {
|
||||
accessKey = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (accessKey.isNull()) {
|
||||
accessKey = unusedKeys.takeFirst();
|
||||
}
|
||||
unusedKeys.removeOne(accessKey);
|
||||
makeAccessKeyLabel(accessKey, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AKN_Handler::hideAccessKeys()
|
||||
{
|
||||
if (!m_accessKeyLabels.isEmpty() && m_view) {
|
||||
for (int i = 0; i < m_accessKeyLabels.count(); ++i) {
|
||||
QLabel* label = m_accessKeyLabels[i];
|
||||
label->hide();
|
||||
label->deleteLater();
|
||||
}
|
||||
m_accessKeyLabels.clear();
|
||||
m_accessKeyNodes.clear();
|
||||
m_view->update();
|
||||
|
||||
// Uninstall event filter and disconnect loadStarted
|
||||
qApp->removeEventFilter(this);
|
||||
disconnect(m_view, SIGNAL(loadStarted()), this, SLOT(hideAccessKeys()));
|
||||
}
|
||||
|
||||
m_accessKeysVisible = false;
|
||||
}
|
||||
|
||||
void AKN_Handler::makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element)
|
||||
{
|
||||
QLabel* label = new QLabel(m_view);
|
||||
label->setText(QString(QLatin1String("<b>%1</b>")).arg(accessKey));
|
||||
|
||||
QPalette p = QToolTip::palette();
|
||||
QColor color = QColor(220, 243, 253);
|
||||
color.setAlpha(175);
|
||||
p.setColor(QPalette::Window, color);
|
||||
|
||||
label->setPalette(p);
|
||||
label->setAutoFillBackground(true);
|
||||
label->setFrameStyle(QFrame::Box | QFrame::Plain);
|
||||
QPoint point = element.geometry().center();
|
||||
point -= m_view->page()->mainFrame()->scrollPosition();
|
||||
label->move(point);
|
||||
label->show();
|
||||
point.setX(point.x() - label->width() / 2);
|
||||
label->move(point);
|
||||
m_accessKeyLabels.append(label);
|
||||
m_accessKeyNodes[accessKey] = element;
|
||||
}
|
71
src/plugins/AccessKeysNavigation/akn_handler.h
Normal file
71
src/plugins/AccessKeysNavigation/akn_handler.h
Normal file
@ -0,0 +1,71 @@
|
||||
/* ============================================================
|
||||
* Access Keys Navigation plugin for QupZilla
|
||||
* Copyright (C) 2012 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 AKN_HANDLER_H
|
||||
#define AKN_HANDLER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTime>
|
||||
#include <QHash>
|
||||
#include <QWebElement>
|
||||
|
||||
class QKeyEvent;
|
||||
class QWebElement;
|
||||
class QTime;
|
||||
class QLabel;
|
||||
|
||||
class WebView;
|
||||
|
||||
class AKN_Handler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AKN_Handler(const QString &sPath, QObject* parent = 0);
|
||||
|
||||
QString settingsPath();
|
||||
void loadSettings();
|
||||
|
||||
bool handleKeyPress(QObject* obj, QKeyEvent* event);
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void showAccessKeys();
|
||||
void hideAccessKeys();
|
||||
|
||||
private:
|
||||
void triggerShowAccessKeys();
|
||||
|
||||
void makeAccessKeyLabel(const QChar &accessKey, const QWebElement &element);
|
||||
void handleAccessKey(QKeyEvent* event);
|
||||
|
||||
WebView* m_view;
|
||||
|
||||
QList<QLabel*> m_accessKeyLabels;
|
||||
QHash<QChar, QWebElement> m_accessKeyNodes;
|
||||
bool m_accessKeysVisible;
|
||||
|
||||
Qt::Key m_key;
|
||||
bool m_isDoublePress;
|
||||
QTime m_lastKeyPressTime;
|
||||
QString m_settingsPath;
|
||||
};
|
||||
|
||||
#endif // AKN_HANDLER_H
|
89
src/plugins/AccessKeysNavigation/akn_plugin.cpp
Normal file
89
src/plugins/AccessKeysNavigation/akn_plugin.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/* ============================================================
|
||||
* Access Keys Navigation plugin for QupZilla
|
||||
* Copyright (C) 2012 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 "akn_plugin.h"
|
||||
#include "akn_handler.h"
|
||||
#include "akn_settings.h"
|
||||
#include "pluginproxy.h"
|
||||
#include "qupzilla.h"
|
||||
|
||||
#include <QTranslator>
|
||||
|
||||
AKN_Plugin::AKN_Plugin()
|
||||
: QObject()
|
||||
, m_handler(0)
|
||||
{
|
||||
}
|
||||
|
||||
PluginSpec AKN_Plugin::pluginSpec()
|
||||
{
|
||||
PluginSpec spec;
|
||||
spec.name = "Access Keys Navigation";
|
||||
spec.info = "Access keys navigation for QupZilla";
|
||||
spec.description = "Provides support for navigating in webpages by keyboard shortcuts";
|
||||
spec.version = "0.1.0";
|
||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||
spec.icon = QPixmap(":/accesskeysnavigation/data/icon.png");
|
||||
spec.hasSettings = true;
|
||||
|
||||
return spec;
|
||||
}
|
||||
|
||||
void AKN_Plugin::init(const QString &sPath)
|
||||
{
|
||||
m_handler = new AKN_Handler(sPath, this);
|
||||
|
||||
QZ_REGISTER_EVENT_HANDLER(PluginProxy::KeyPressHandler);
|
||||
}
|
||||
|
||||
void AKN_Plugin::unload()
|
||||
{
|
||||
m_handler->deleteLater();
|
||||
}
|
||||
|
||||
bool AKN_Plugin::testPlugin()
|
||||
{
|
||||
// Let's be sure, require latest version of QupZilla
|
||||
|
||||
return (QupZilla::VERSION == "1.1.8");
|
||||
}
|
||||
|
||||
QTranslator* AKN_Plugin::getTranslator(const QString &locale)
|
||||
{
|
||||
QTranslator* translator = new QTranslator();
|
||||
translator->load(":/accesskeysnavigation/locale/" + locale);
|
||||
return translator;
|
||||
}
|
||||
|
||||
void AKN_Plugin::showSettings(QWidget* parent)
|
||||
{
|
||||
AKN_Settings* settings = new AKN_Settings(m_handler, parent);
|
||||
settings->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
settings->show();
|
||||
}
|
||||
|
||||
bool AKN_Plugin::keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event)
|
||||
{
|
||||
if (type == Qz::ON_WebView) {
|
||||
return m_handler->handleKeyPress(obj, event);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(AccessKeysNavigation, AKN_Plugin)
|
47
src/plugins/AccessKeysNavigation/akn_plugin.h
Normal file
47
src/plugins/AccessKeysNavigation/akn_plugin.h
Normal file
@ -0,0 +1,47 @@
|
||||
/* ============================================================
|
||||
* Access Keys Navigation plugin for QupZilla
|
||||
* Copyright (C) 2012 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 AKN_PLUGIN_H
|
||||
#define AKN_PLUGIN_H
|
||||
|
||||
#include "plugininterface.h"
|
||||
|
||||
class AKN_Handler;
|
||||
|
||||
class AKN_Plugin : public QObject, public PluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
|
||||
public:
|
||||
AKN_Plugin();
|
||||
PluginSpec pluginSpec();
|
||||
|
||||
void init(const QString &sPath);
|
||||
void unload();
|
||||
bool testPlugin();
|
||||
|
||||
QTranslator* getTranslator(const QString &locale);
|
||||
void showSettings(QWidget* parent = 0);
|
||||
|
||||
bool keyPress(const Qz::ObjectName &type, QObject* obj, QKeyEvent* event);
|
||||
|
||||
private:
|
||||
AKN_Handler* m_handler;
|
||||
};
|
||||
|
||||
#endif // AKN_PLUGIN_H
|
9
src/plugins/AccessKeysNavigation/akn_res.qrc
Normal file
9
src/plugins/AccessKeysNavigation/akn_res.qrc
Normal file
@ -0,0 +1,9 @@
|
||||
<RCC>
|
||||
<qresource prefix="/accesskeysnavigation">
|
||||
<file>data/icon.png</file>
|
||||
<file>data/copyright</file>
|
||||
<file>locale/cs_CZ.qm</file>
|
||||
<file>locale/sr_BA.qm</file>
|
||||
<file>locale/sr_RS.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
66
src/plugins/AccessKeysNavigation/akn_settings.cpp
Normal file
66
src/plugins/AccessKeysNavigation/akn_settings.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/* ============================================================
|
||||
* Access Keys Navigation plugin for QupZilla
|
||||
* Copyright (C) 2012 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 "akn_settings.h"
|
||||
#include "ui_akn_settings.h"
|
||||
#include "akn_handler.h"
|
||||
#include "licenseviewer.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QTextBrowser>
|
||||
|
||||
AKN_Settings::AKN_Settings(AKN_Handler* handler, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::AKN_Settings)
|
||||
, m_handler(handler)
|
||||
, m_settingsPath(handler->settingsPath())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QSettings settings(m_settingsPath, QSettings::IniFormat);
|
||||
settings.beginGroup("AccessKeysNavigation");
|
||||
ui->key->setCurrentIndex(settings.value("Key", 0).toInt());
|
||||
ui->doubleClick->setChecked(settings.value("DoublePress", true).toBool());
|
||||
settings.endGroup();
|
||||
|
||||
connect(ui->licence, SIGNAL(clicked()), this, SLOT(showLicence()));
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(dialogAccepted()));
|
||||
}
|
||||
|
||||
void AKN_Settings::dialogAccepted()
|
||||
{
|
||||
QSettings settings(m_settingsPath, QSettings::IniFormat);
|
||||
settings.beginGroup("AccessKeysNavigation");
|
||||
settings.setValue("Key", ui->key->currentIndex());
|
||||
settings.setValue("DoublePress", ui->doubleClick->isChecked());
|
||||
settings.endGroup();
|
||||
|
||||
m_handler->loadSettings();
|
||||
}
|
||||
|
||||
void AKN_Settings::showLicence()
|
||||
{
|
||||
LicenseViewer* v = new LicenseViewer(this);
|
||||
v->setLicenseFile(":accesskeysnavigation/data/copyright");
|
||||
v->show();
|
||||
}
|
||||
|
||||
AKN_Settings::~AKN_Settings()
|
||||
{
|
||||
delete ui;
|
||||
}
|
49
src/plugins/AccessKeysNavigation/akn_settings.h
Normal file
49
src/plugins/AccessKeysNavigation/akn_settings.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* ============================================================
|
||||
* Access Keys Navigation plugin for QupZilla
|
||||
* Copyright (C) 2012 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 AKN_SETTINGS_H
|
||||
#define AKN_SETTINGS_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AKN_Settings;
|
||||
}
|
||||
|
||||
class AKN_Handler;
|
||||
|
||||
class AKN_Settings : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AKN_Settings(AKN_Handler* handler, QWidget* parent = 0);
|
||||
~AKN_Settings();
|
||||
|
||||
private slots:
|
||||
void dialogAccepted();
|
||||
void showLicence();
|
||||
|
||||
private:
|
||||
Ui::AKN_Settings* ui;
|
||||
|
||||
AKN_Handler* m_handler;
|
||||
QString m_settingsPath;
|
||||
};
|
||||
|
||||
#endif // AKN_SETTINGS_H
|
144
src/plugins/AccessKeysNavigation/akn_settings.ui
Normal file
144
src/plugins/AccessKeysNavigation/akn_settings.ui
Normal file
@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AKN_Settings</class>
|
||||
<widget class="QDialog" name="AKN_Settings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>470</width>
|
||||
<height>146</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Access Keys Navigation</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><h1>Access Keys Navigation</h1></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="key">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ctrl</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Alt</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="doubleClick">
|
||||
<property name="text">
|
||||
<string>Double press</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Key for showing access keys:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<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>
|
||||
<item row="0" column="3">
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="licence">
|
||||
<property name="text">
|
||||
<string>Licence</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AKN_Settings</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AKN_Settings</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
20
src/plugins/AccessKeysNavigation/data/copyright
Normal file
20
src/plugins/AccessKeysNavigation/data/copyright
Normal file
@ -0,0 +1,20 @@
|
||||
Access Keys showing function is under following license:
|
||||
|
||||
/*
|
||||
* Copyright 2008-2009 Benjamin C. Meyer <ben@meyerhome.net>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
BIN
src/plugins/AccessKeysNavigation/data/icon.png
Normal file
BIN
src/plugins/AccessKeysNavigation/data/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 656 B |
47
src/plugins/AccessKeysNavigation/translations/cs_CZ.ts
Normal file
47
src/plugins/AccessKeysNavigation/translations/cs_CZ.ts
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="cs_CZ">
|
||||
<context>
|
||||
<name>AKN_Settings</name>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="14"/>
|
||||
<source>Access Keys Navigation</source>
|
||||
<translation>Klávesové zkratky</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="20"/>
|
||||
<source><h1>Access Keys Navigation</h1></source>
|
||||
<translation><h1>Klávesové zkratky</h1></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="33"/>
|
||||
<source>Ctrl</source>
|
||||
<translation>Ctrl</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="38"/>
|
||||
<source>Alt</source>
|
||||
<translation>Alt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="43"/>
|
||||
<source>Shift</source>
|
||||
<translation>Shift</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="51"/>
|
||||
<source>Double press</source>
|
||||
<translation>Dvojitý stisk</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="58"/>
|
||||
<source>Key for showing access keys:</source>
|
||||
<translation>Klávesa pro zobrazení zkratek:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="103"/>
|
||||
<source>Licence</source>
|
||||
<translation>Licence</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
47
src/plugins/AccessKeysNavigation/translations/de_DE.ts
Normal file
47
src/plugins/AccessKeysNavigation/translations/de_DE.ts
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="de">
|
||||
<context>
|
||||
<name>AKN_Settings</name>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="14"/>
|
||||
<source>Access Keys Navigation</source>
|
||||
<translation>Tastennavigation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="20"/>
|
||||
<source><h1>Access Keys Navigation</h1></source>
|
||||
<translation><h1>Tastennavigation</h1></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="33"/>
|
||||
<source>Ctrl</source>
|
||||
<translation>Strg</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="38"/>
|
||||
<source>Alt</source>
|
||||
<translation>Alt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="43"/>
|
||||
<source>Shift</source>
|
||||
<translation>Umschalt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="51"/>
|
||||
<source>Double press</source>
|
||||
<translation>Doppelter Tastendruck</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="58"/>
|
||||
<source>Key for showing access keys:</source>
|
||||
<translation>Anzeige der Tastennavigation mit:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="103"/>
|
||||
<source>Licence</source>
|
||||
<translation>Lizenz</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
47
src/plugins/AccessKeysNavigation/translations/sr_BA.ts
Normal file
47
src/plugins/AccessKeysNavigation/translations/sr_BA.ts
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="sr_BA">
|
||||
<context>
|
||||
<name>AKN_Settings</name>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="14"/>
|
||||
<source>Access Keys Navigation</source>
|
||||
<translation>Навигација помоћу тастера приступа</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="20"/>
|
||||
<source><h1>Access Keys Navigation</h1></source>
|
||||
<translation><h1>Навигација помоћу тастера приступа</h1></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="33"/>
|
||||
<source>Ctrl</source>
|
||||
<translation>Ctrl</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="38"/>
|
||||
<source>Alt</source>
|
||||
<translation>Alt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="43"/>
|
||||
<source>Shift</source>
|
||||
<translation>Shift</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="51"/>
|
||||
<source>Double press</source>
|
||||
<translation>Двоструко</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="58"/>
|
||||
<source>Key for showing access keys:</source>
|
||||
<translation>Активација приказа тастера приступа:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="103"/>
|
||||
<source>Licence</source>
|
||||
<translation>Лиценца</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
47
src/plugins/AccessKeysNavigation/translations/sr_RS.ts
Normal file
47
src/plugins/AccessKeysNavigation/translations/sr_RS.ts
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.0" language="sr_RS">
|
||||
<context>
|
||||
<name>AKN_Settings</name>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="14"/>
|
||||
<source>Access Keys Navigation</source>
|
||||
<translation>Навигација помоћу тастера приступа</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="20"/>
|
||||
<source><h1>Access Keys Navigation</h1></source>
|
||||
<translation><h1>Навигација помоћу тастера приступа</h1></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="33"/>
|
||||
<source>Ctrl</source>
|
||||
<translation>Ctrl</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="38"/>
|
||||
<source>Alt</source>
|
||||
<translation>Alt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="43"/>
|
||||
<source>Shift</source>
|
||||
<translation>Shift</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="51"/>
|
||||
<source>Double press</source>
|
||||
<translation>Двоструко</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="58"/>
|
||||
<source>Key for showing access keys:</source>
|
||||
<translation>Активација приказа тастера приступа:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../akn_settings.ui" line="103"/>
|
||||
<source>Licence</source>
|
||||
<translation>Лиценца</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
@ -19,6 +19,9 @@ HEADERS = \
|
||||
mousegesturesplugin.h \
|
||||
mousegesturessettingsdialog.h
|
||||
|
||||
FORMS += \
|
||||
mousegesturessettingsdialog.ui
|
||||
|
||||
RESOURCES = mousegestures.qrc
|
||||
|
||||
TRANSLATIONS = translations/cs_CZ.ts \
|
||||
@ -28,6 +31,3 @@ TRANSLATIONS = translations/cs_CZ.ts \
|
||||
translations/zh_TW.ts \
|
||||
|
||||
include(../../plugins.pri)
|
||||
|
||||
FORMS += \
|
||||
mousegesturessettingsdialog.ui
|
||||
|
@ -1,11 +1,29 @@
|
||||
/* ============================================================
|
||||
* Mouse Gestures plugin for QupZilla
|
||||
* Copyright (C) 2012 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 "mousegestures.h"
|
||||
#include "QjtMouseGestureFilter.h"
|
||||
#include "QjtMouseGesture.h"
|
||||
#include "webview.h"
|
||||
#include "mainapplication.h"
|
||||
#include "qupzilla.h"
|
||||
#include "mousegesturessettingsdialog.h"
|
||||
|
||||
#include "QjtMouseGestureFilter.h"
|
||||
#include "QjtMouseGesture.h"
|
||||
|
||||
MouseGestures::MouseGestures(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
@ -1,7 +1,23 @@
|
||||
/* ============================================================
|
||||
* Mouse Gestures plugin for QupZilla
|
||||
* Copyright (C) 2012 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 MOUSEGESTURES_H
|
||||
#define MOUSEGESTURES_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QMouseEvent>
|
||||
|
||||
|
@ -1,3 +1,20 @@
|
||||
/* ============================================================
|
||||
* Mouse Gestures plugin for QupZilla
|
||||
* Copyright (C) 2012 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 "mousegesturesplugin.h"
|
||||
#include "pluginproxy.h"
|
||||
#include "mousegestures.h"
|
||||
@ -16,7 +33,7 @@ PluginSpec MouseGesturesPlugin::pluginSpec()
|
||||
PluginSpec spec;
|
||||
spec.name = "Mouse Gestures";
|
||||
spec.info = "Mouse gestures for QupZilla";
|
||||
spec.description = "Provides support for navigating by mouse gestures through webpages";
|
||||
spec.description = "Provides support for navigating in webpages by mouse gestures";
|
||||
spec.version = "0.1.0";
|
||||
spec.author = "David Rosca <nowrep@gmail.com>";
|
||||
spec.icon = QPixmap(":/mousegestures/data/icon.png");
|
||||
|
@ -1,3 +1,20 @@
|
||||
/* ============================================================
|
||||
* Mouse Gestures plugin for QupZilla
|
||||
* Copyright (C) 2012 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 MOUSEGESTURESPLUGIN_H
|
||||
#define MOUSEGESTURESPLUGIN_H
|
||||
|
||||
|
@ -1,6 +1,23 @@
|
||||
/* ============================================================
|
||||
* Mouse Gestures plugin for QupZilla
|
||||
* Copyright (C) 2012 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 "mousegesturessettingsdialog.h"
|
||||
#include "ui_mousegesturessettingsdialog.h"
|
||||
#include "globalfunctions.h"
|
||||
#include "licenseviewer.h"
|
||||
|
||||
MouseGesturesSettingsDialog::MouseGesturesSettingsDialog(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
@ -19,11 +36,8 @@ MouseGesturesSettingsDialog::~MouseGesturesSettingsDialog()
|
||||
|
||||
void MouseGesturesSettingsDialog::showLicense()
|
||||
{
|
||||
QTextBrowser* b = new QTextBrowser();
|
||||
b->setAttribute(Qt::WA_DeleteOnClose);
|
||||
b->setWindowTitle(tr("License Viewer"));
|
||||
b->resize(450, 500);
|
||||
b->setText(qz_readAllFileContents(":mousegestures/data/copyright"));
|
||||
qz_centerWidgetOnScreen(b);
|
||||
b->show();
|
||||
LicenseViewer* v = new LicenseViewer(this);
|
||||
v->setLicenseFile(":mousegestures/data/copyright");
|
||||
|
||||
v->show();
|
||||
}
|
||||
|
@ -1,3 +1,20 @@
|
||||
/* ============================================================
|
||||
* Mouse Gestures plugin for QupZilla
|
||||
* Copyright (C) 2012 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 MOUSEGESTURESSETTINGSDIALOG_H
|
||||
#define MOUSEGESTURESSETTINGSDIALOG_H
|
||||
|
||||
|
@ -58,10 +58,5 @@
|
||||
<source>License</source>
|
||||
<translation>Licence</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mousegesturessettingsdialog.cpp" line="24"/>
|
||||
<source>License Viewer</source>
|
||||
<translation>Prohlížeč licence</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -58,10 +58,5 @@
|
||||
<source>License</source>
|
||||
<translation>Lizenz</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mousegesturessettingsdialog.cpp" line="24"/>
|
||||
<source>License Viewer</source>
|
||||
<translation>Lizenz anzeigen</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -58,10 +58,5 @@
|
||||
<source>License</source>
|
||||
<translation>Лиценца</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mousegesturessettingsdialog.cpp" line="24"/>
|
||||
<source>License Viewer</source>
|
||||
<translation>Преглед лиценце</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -58,10 +58,5 @@
|
||||
<source>License</source>
|
||||
<translation>Лиценца</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mousegesturessettingsdialog.cpp" line="24"/>
|
||||
<source>License Viewer</source>
|
||||
<translation>Преглед лиценце</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -58,10 +58,5 @@
|
||||
<source>License</source>
|
||||
<translation>憑證</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mousegesturessettingsdialog.cpp" line="24"/>
|
||||
<source>License Viewer</source>
|
||||
<translation>檢視憑證</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@ -4,27 +4,27 @@
|
||||
<context>
|
||||
<name>TestPlugin</name>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="70"/>
|
||||
<location filename="../testplugin.cpp" line="92"/>
|
||||
<source>Close</source>
|
||||
<translation>Zavřít</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="81"/>
|
||||
<location filename="../testplugin.cpp" line="103"/>
|
||||
<source>Example Plugin Settings</source>
|
||||
<translation>Nastavení ukázkového doplňku</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="105"/>
|
||||
<location filename="../testplugin.cpp" line="127"/>
|
||||
<source>My first plugin action</source>
|
||||
<translation>Moje první akce z doplňku</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="117"/>
|
||||
<location filename="../testplugin.cpp" line="139"/>
|
||||
<source>Hello</source>
|
||||
<translation>Ahoj</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="117"/>
|
||||
<location filename="../testplugin.cpp" line="139"/>
|
||||
<source>First plugin action works :-)</source>
|
||||
<translation>První akce funguje :-)</translation>
|
||||
</message>
|
||||
|
@ -4,27 +4,27 @@
|
||||
<context>
|
||||
<name>TestPlugin</name>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="70"/>
|
||||
<location filename="../testplugin.cpp" line="92"/>
|
||||
<source>Close</source>
|
||||
<translation>Schließen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="81"/>
|
||||
<location filename="../testplugin.cpp" line="103"/>
|
||||
<source>Example Plugin Settings</source>
|
||||
<translation>Einstellungen des Beispiel-Plugins</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="105"/>
|
||||
<location filename="../testplugin.cpp" line="127"/>
|
||||
<source>My first plugin action</source>
|
||||
<translation>Meine erste Aktion</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="117"/>
|
||||
<location filename="../testplugin.cpp" line="139"/>
|
||||
<source>Hello</source>
|
||||
<translation>Hallo</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="117"/>
|
||||
<location filename="../testplugin.cpp" line="139"/>
|
||||
<source>First plugin action works :-)</source>
|
||||
<translation>Meine erste Aktion funktioniert :-)</translation>
|
||||
</message>
|
||||
|
@ -4,27 +4,27 @@
|
||||
<context>
|
||||
<name>TestPlugin</name>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="70"/>
|
||||
<location filename="../testplugin.cpp" line="92"/>
|
||||
<source>Close</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="81"/>
|
||||
<location filename="../testplugin.cpp" line="103"/>
|
||||
<source>Example Plugin Settings</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="105"/>
|
||||
<location filename="../testplugin.cpp" line="127"/>
|
||||
<source>My first plugin action</source>
|
||||
<translation>Η ενέργεια του πρώτου μου προσθέτου</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="117"/>
|
||||
<location filename="../testplugin.cpp" line="139"/>
|
||||
<source>Hello</source>
|
||||
<translation>Γεια</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../testplugin.cpp" line="117"/>
|
||||
<location filename="../testplugin.cpp" line="139"/>
|
||||
<source>First plugin action works :-)</source>
|
||||
<translation>Η ενέργεια του πρώτου προσθέτου δουλεύει :-)</translation>
|
||||
</message>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user