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

Access Keys Navigation plugin now add also lower/upper case chars.

- imporved pages screen = removing scrollbars from screen
This commit is contained in:
nowrep 2012-03-07 12:19:54 +01:00
parent b5db8a21c9
commit 0e4fd462ba
9 changed files with 138 additions and 96 deletions

View File

@ -173,9 +173,10 @@ void BookmarksImportDialog::iconFetched(const QImage &image, QTreeWidgetItem* it
Bookmark b = item->data(0, Qt::UserRole + 10).value<Bookmark>();
m_exportedBookmarks.removeOne(b);
b.image = image;
m_exportedBookmarks.append(b);
int index = m_exportedBookmarks.indexOf(b);
if (index != -1) {
m_exportedBookmarks[index].image = image;
}
}
bool BookmarksImportDialog::exportedOK()

View File

@ -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;
}
}
}
}

View File

@ -27,15 +27,13 @@
#include <QtConcurrentRun>
#include <QPushButton>
QImage scale(QImage image)
{
return image.scaled(QSize(470, 370), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
}
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);
@ -44,6 +42,8 @@ PageScreen::PageScreen(WebView* view, QWidget* parent)
ui->label->setMovie(mov);
mov->start();
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()));
@ -52,7 +52,8 @@ PageScreen::PageScreen(WebView* view, QWidget* parent)
void PageScreen::dialogAccepted()
{
const QString &path = QFileDialog::getSaveFileName(this, tr("Save Page Screen..."), tr("screen.png"));
const QString &path = QFileDialog::getSaveFileName(this, tr("Save Page Screen..."),
QString("%1.png").arg(qz_filterCharsFromFilename(m_pageTitle)));
if (!path.isEmpty()) {
m_pageImage.save(path);
@ -71,12 +72,28 @@ void PageScreen::createThumbnail()
page->mainFrame()->render(&painter);
painter.end();
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(scale, m_pageImage));
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()

View File

@ -40,6 +40,8 @@ public:
explicit PageScreen(WebView* view, QWidget* parent);
~PageScreen();
QImage scaleImage();
private slots:
void createThumbnail();
void showImage();
@ -52,8 +54,11 @@ private:
Ui::PageScreen* ui;
WebView* m_view;
QImage m_pageImage;
QString m_pageTitle;
QFutureWatcher<QImage>* m_imageScaling;
int m_horizontalScrollbarSize;
int m_verticalScrollbarSize;
};
#endif // PAGESCREEN_H

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<width>562</width>
<height>421</height>
</rect>
</property>
@ -18,7 +18,7 @@
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
<number>6</number>
</property>
<property name="rightMargin">
<number>0</number>
@ -36,8 +36,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<height>372</height>
<width>562</width>
<height>366</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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>

View File

@ -171,7 +171,7 @@ void AKN_Handler::handleAccessKey(QKeyEvent* event)
return;
}
QChar key = text.at(0).toUpper();
QChar key = text.at(0);
if (m_accessKeyNodes.contains(key)) {
QWebElement element = m_accessKeyNodes[key];
@ -227,6 +227,9 @@ void AKN_Handler::showAccessKeys()
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