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

Qt5: Added new option to use Caret Browsing

It can be enabled from Preferences -> Browsing,
Menu View or with F7 shortcut.
This commit is contained in:
nowrep 2012-12-22 13:52:46 +01:00
parent 44693080cb
commit bdc9a0417a
5 changed files with 42 additions and 0 deletions

View File

@ -373,6 +373,7 @@ void MainApplication::loadSettings()
m_websettings->setDefaultTextEncoding(settings.value("DefaultEncoding", m_websettings->defaultTextEncoding()).toString()); m_websettings->setDefaultTextEncoding(settings.value("DefaultEncoding", m_websettings->defaultTextEncoding()).toString());
#if QT_VERSION >= 0x050000 #if QT_VERSION >= 0x050000
m_websettings->setAttribute(QWebSettings::CaretBrowsingEnabled, settings.value("CaretBrowsing", false).toBool());
m_websettings->setAttribute(QWebSettings::ScrollAnimatorEnabled, settings.value("AnimateScrolling", true).toBool()); m_websettings->setAttribute(QWebSettings::ScrollAnimatorEnabled, settings.value("AnimateScrolling", true).toBool());
#endif #endif

View File

@ -401,6 +401,12 @@ void QupZilla::setupMenu()
m_menuEncoding = new QMenu(this); m_menuEncoding = new QMenu(this);
actionEncoding->setMenu(m_menuEncoding); actionEncoding->setMenu(m_menuEncoding);
connect(m_menuEncoding, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu())); connect(m_menuEncoding, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu()));
#if QT_VERSION >= 0x050000
m_actionCaretBrowsing = new QAction(tr("Enable &Caret Browsing"), this);
m_actionCaretBrowsing->setCheckable(true);
m_actionCaretBrowsing->setShortcut(QKeySequence("F7"));
connect(m_actionCaretBrowsing, SIGNAL(triggered()), this, SLOT(triggerCaretBrowsing()));
#endif
QMenu* toolbarsMenu = new QMenu(tr("Toolbars")); QMenu* toolbarsMenu = new QMenu(tr("Toolbars"));
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
@ -422,6 +428,9 @@ void QupZilla::setupMenu()
m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), this, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-")); m_menuView->addAction(QIcon::fromTheme("zoom-out"), tr("Zoom &Out"), this, SLOT(zoomOut()))->setShortcut(QKeySequence("Ctrl+-"));
m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0")); m_menuView->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(zoomReset()))->setShortcut(QKeySequence("Ctrl+0"));
m_menuView->addSeparator(); m_menuView->addSeparator();
#if QT_VERSION >= 0x050000
m_menuView->addAction(m_actionCaretBrowsing);
#endif
m_menuView->addAction(actionEncoding); m_menuView->addAction(actionEncoding);
m_menuView->addSeparator(); m_menuView->addSeparator();
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), this, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U")); m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), this, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
@ -969,6 +978,10 @@ void QupZilla::aboutToShowViewMenu()
#endif #endif
m_actionShowStatusbar->setChecked(statusBar()->isVisible()); m_actionShowStatusbar->setChecked(statusBar()->isVisible());
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible()); m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());
#if QT_VERSION >= 0x050000
m_actionCaretBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
#endif
} }
void QupZilla::aboutToShowEditMenu() void QupZilla::aboutToShowEditMenu()
@ -1075,6 +1088,20 @@ void QupZilla::changeEncoding()
} }
} }
#if QT_VERSION >= 0x050000
void QupZilla::triggerCaretBrowsing()
{
bool enable = !mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled);
Settings settings;
settings.beginGroup("Web-Browser-Settings");
settings.setValue("CaretBrowsing", enable);
settings.endGroup();
mApp->webSettings()->setAttribute(QWebSettings::CaretBrowsingEnabled, enable);
}
#endif
void QupZilla::bookmarkPage() void QupZilla::bookmarkPage()
{ {
mApp->browsingLibrary()->bookmarksManager()->addBookmark(weView()); mApp->browsingLibrary()->bookmarksManager()->addBookmark(weView());

View File

@ -188,6 +188,10 @@ private slots:
void fullScreen(bool make); void fullScreen(bool make);
void changeEncoding(); void changeEncoding();
#if QT_VERSION >= 0x050000
void triggerCaretBrowsing();
#endif
void closeWindow(); void closeWindow();
bool quitApp(); bool quitApp();
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
@ -260,6 +264,7 @@ private:
QAction* m_actionPrivateBrowsing; QAction* m_actionPrivateBrowsing;
QAction* m_actionStop; QAction* m_actionStop;
QAction* m_actionReload; QAction* m_actionReload;
QAction* m_actionCaretBrowsing;
QAction* m_actionRestoreTab; QAction* m_actionRestoreTab;
QLabel* m_privateBrowsing; QLabel* m_privateBrowsing;

View File

@ -244,6 +244,7 @@ Preferences::Preferences(QupZilla* mainClass, QWidget* parent)
ui->allowDNSPrefetch->setChecked(settings.value("DNS-Prefetch", false).toBool()); ui->allowDNSPrefetch->setChecked(settings.value("DNS-Prefetch", false).toBool());
ui->linksInFocusChain->setChecked(settings.value("IncludeLinkInFocusChain", false).toBool()); ui->linksInFocusChain->setChecked(settings.value("IncludeLinkInFocusChain", false).toBool());
ui->zoomTextOnly->setChecked(settings.value("zoomTextOnly", false).toBool()); ui->zoomTextOnly->setChecked(settings.value("zoomTextOnly", false).toBool());
ui->caretBrowsing->setChecked(settings.value("CaretBrowsing", false).toBool());
ui->animateScrolling->setChecked(settings.value("AnimateScrolling", true).toBool()); ui->animateScrolling->setChecked(settings.value("AnimateScrolling", true).toBool());
ui->printEBackground->setChecked(settings.value("PrintElementBackground", true).toBool()); ui->printEBackground->setChecked(settings.value("PrintElementBackground", true).toBool());
ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt()); ui->wheelScroll->setValue(settings.value("wheelScrollLines", qApp->wheelScrollLines()).toInt());
@ -891,6 +892,7 @@ void Preferences::saveSettings()
settings.setValue("JavaScriptCanAccessClipboard", ui->jscanAccessClipboard->isChecked()); settings.setValue("JavaScriptCanAccessClipboard", ui->jscanAccessClipboard->isChecked());
settings.setValue("IncludeLinkInFocusChain", ui->linksInFocusChain->isChecked()); settings.setValue("IncludeLinkInFocusChain", ui->linksInFocusChain->isChecked());
settings.setValue("zoomTextOnly", ui->zoomTextOnly->isChecked()); settings.setValue("zoomTextOnly", ui->zoomTextOnly->isChecked());
settings.setValue("CaretBrowsing", ui->caretBrowsing->isChecked());
settings.setValue("AnimateScrolling", ui->animateScrolling->isChecked()); settings.setValue("AnimateScrolling", ui->animateScrolling->isChecked());
settings.setValue("PrintElementBackground", ui->printEBackground->isChecked()); settings.setValue("PrintElementBackground", ui->printEBackground->isChecked());
settings.setValue("wheelScrollLines", ui->wheelScroll->value()); settings.setValue("wheelScrollLines", ui->wheelScroll->value());

View File

@ -1061,6 +1061,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="caretBrowsing">
<property name="text">
<string>Enable caret browsing</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="zoomTextOnly"> <widget class="QCheckBox" name="zoomTextOnly">
<property name="text"> <property name="text">