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

Global shortcuts to load pages in Speed Dial (Ctrl + Number)

- Ctrl + 1,2,3 ... 9 will load dials on the number position
- Alt + 1,2,3 ... 8 will switch to tab on the number position
   * Alt + 9 will switch to last tab
This commit is contained in:
nowrep 2012-02-05 17:13:08 +01:00
parent 7167ce4a03
commit 30df150fe0
3 changed files with 63 additions and 33 deletions

View File

@ -62,6 +62,7 @@
#include "enhancedmenu.h"
#include "settings.h"
#include "webtab.h"
#include "speeddial.h"
const QString QupZilla::VERSION = "1.1.5";
const QString QupZilla::BUILDTIME = __DATE__" "__TIME__;
@ -1542,6 +1543,8 @@ void QupZilla::resizeEvent(QResizeEvent* event)
void QupZilla::keyPressEvent(QKeyEvent* event)
{
int number = -1;
switch (event->key()) {
case Qt::Key_Back:
weView()->back();
@ -1616,33 +1619,54 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
}
break;
case Qt::Key_0:
case Qt::Key_1:
number = 1;
break;
case Qt::Key_2:
number = 2;
break;
case Qt::Key_3:
number = 3;
break;
case Qt::Key_4:
number = 4;
break;
case Qt::Key_5:
number = 5;
break;
case Qt::Key_6:
number = 6;
break;
case Qt::Key_7:
number = 7;
break;
case Qt::Key_8:
qDebug() << event->modifiers();
if (event->modifiers() & Qt::AltModifier) {
m_tabWidget->setCurrentIndex(event->text().toInt() - 1);
event->accept();
}
number = 8;
break;
case Qt::Key_9:
number = 9;
break;
case Qt::Key_9:
if (event->modifiers() & Qt::AltModifier) {
m_tabWidget->setCurrentIndex(m_tabWidget->count() - 1);
event->accept();
default:
break;
}
default:
if (number != -1) {
if (event->modifiers() & Qt::AltModifier) {
if (number == 9) {
number = m_tabWidget->count();
}
m_tabWidget->setCurrentIndex(number - 1);
return;
}
qDebug("event");
if (event->modifiers() & Qt::ControlModifier) {
const QUrl &url = mApp->plugins()->speedDial()->urlForShortcut(number - 1);
if (url.isValid()) {
loadAddress(url);
return;
}
}
}
QMainWindow::keyPressEvent(event);
}

View File

@ -20,6 +20,8 @@
#include "pagethumbnailer.h"
#include "settings.h"
#define ENSURE_LOADED if (!m_loaded) loadSettings();
SpeedDial::SpeedDial(QObject* parent)
: QObject(parent)
, m_maxPagesInRow(4)
@ -61,6 +63,8 @@ void SpeedDial::loadSettings()
void SpeedDial::saveSettings()
{
ENSURE_LOADED;
if (m_webPages.isEmpty()) {
return;
}
@ -77,6 +81,8 @@ void SpeedDial::saveSettings()
SpeedDial::Page SpeedDial::pageForUrl(const QUrl &url)
{
ENSURE_LOADED;
const QString &urlString = url.toString();
foreach(const Page & page, m_webPages) {
@ -90,6 +96,8 @@ SpeedDial::Page SpeedDial::pageForUrl(const QUrl &url)
QUrl SpeedDial::urlForShortcut(int key)
{
ENSURE_LOADED;
if (key < 0 || m_webPages.count() <= key) {
return QUrl();
}
@ -106,6 +114,8 @@ void SpeedDial::addWebFrame(QWebFrame* frame)
void SpeedDial::addPage(const QUrl &url, const QString &title)
{
ENSURE_LOADED;
if (url.isEmpty()) {
return;
}
@ -126,6 +136,8 @@ void SpeedDial::addPage(const QUrl &url, const QString &title)
void SpeedDial::removePage(const Page &page)
{
ENSURE_LOADED;
if (page.url.isEmpty()) {
return;
}
@ -143,45 +155,35 @@ void SpeedDial::removePage(const Page &page)
int SpeedDial::pagesInRow()
{
if (!m_loaded) {
loadSettings();
}
ENSURE_LOADED;
return m_maxPagesInRow;
}
int SpeedDial::sdSize()
{
if (!m_loaded) {
loadSettings();
}
ENSURE_LOADED;
return m_sizeOfSpeedDials;
}
QString SpeedDial::backgroundImage()
{
if (!m_loaded) {
loadSettings();
}
ENSURE_LOADED;
return m_backgroundImage;
}
QString SpeedDial::backgroundImageSize()
{
if (!m_loaded) {
loadSettings();
}
ENSURE_LOADED;
return m_backgroundImageSize;
}
QString SpeedDial::initialScript()
{
if (!m_loaded) {
loadSettings();
}
ENSURE_LOADED;
if (!m_regenerateScript) {
return m_initialScript;

View File

@ -575,25 +575,29 @@ bool WebPage::javaScriptConfirm(QWebFrame* originatingFrame, const QString &msg)
void WebPage::javaScriptAlert(QWebFrame* originatingFrame, const QString &msg)
{
Q_UNUSED(originatingFrame)
if (m_blockAlerts || m_runningLoop) {
return;
}
#ifndef NONBLOCK_JS_DIALOGS
QDialog dialog(view());
QDialog* dialog = new QDialog(view());
Ui_CloseDialog* ui = new Ui_CloseDialog();
ui->setupUi(&dialog);
ui->setupUi(dialog);
ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok);
ui->dontAskAgain->setText(tr("Prevent this page from creating additional dialogs"));
ui->textLabel->setText(Qt::escape(msg));
ui->iconLabel->setPixmap(mApp->style()->standardPixmap(QStyle::SP_MessageBoxInformation));
ui->buttonBox->setFocus();
dialog.setWindowTitle(tr("JavaScript alert - %1").arg(originatingFrame->url().host()));
dialog.exec();
dialog->setWindowTitle(tr("JavaScript alert - %1").arg(url().host()));
dialog->exec();
if (ui->dontAskAgain->isChecked()) {
m_blockAlerts = true;
}
delete dialog;
#else
WebView* webView = qobject_cast<WebView*>(originatingFrame->page()->view());
ResizableFrame* widget = new ResizableFrame(webView->overlayForJsAlert());