Skip to content

Commit

Permalink
Don't steal Ctrl+U/B/I shortcuts from page.
Browse files Browse the repository at this point in the history
When writing eg. mail on gmail, you can make text bold,
underline and italic with Ctrl+U/B/I shortcuts.
It will now correctly process the web action instead
of showing bookmarks sidebar, source of page and page info.

Shortcut for bookmarks sidebar has been change to Ctrl+Shift+B
  • Loading branch information
nowrep committed Jan 26, 2013
1 parent 84dc48e commit 32f69c8
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
42 changes: 40 additions & 2 deletions src/lib/app/qupzilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,12 @@ void QupZilla::setupMenu()
m_menuView->addAction(m_actionCaretBrowsing);
m_menuView->addAction(actionEncoding);
m_menuView->addSeparator();
m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), this, SLOT(showSource()))->setShortcut(QKeySequence("Ctrl+U"));
m_actionPageSource = m_menuView->addAction(QIcon::fromTheme("text-html"), tr("&Page Source"), this, SLOT(showSource()));
m_actionPageSource->setShortcut(QKeySequence("Ctrl+U"));
m_actionPageSource->setEnabled(false);
m_menuView->addAction(m_actionShowFullScreen);
connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu()));
connect(m_menuView, SIGNAL(aboutToHide()), this, SLOT(aboutToHideViewMenu()));

/****************
* History Menu *
Expand Down Expand Up @@ -480,7 +483,9 @@ void QupZilla::setupMenu()
**************/
m_menuTools = new QMenu(tr("&Tools"));
m_menuTools->addAction(tr("&Web Search"), this, SLOT(webSearch()))->setShortcut(QKeySequence("Ctrl+K"));
m_menuTools->addAction(QIcon::fromTheme("dialog-information"), tr("Page &Info"), this, SLOT(showPageInfo()))->setShortcut(QKeySequence("Ctrl+I"));
m_actionPageInfo = m_menuTools->addAction(QIcon::fromTheme("dialog-information"), tr("Page &Info"), this, SLOT(showPageInfo()));
m_actionPageInfo->setShortcut(QKeySequence("Ctrl+I"));
m_actionPageInfo->setEnabled(false);
m_menuTools->addSeparator();
m_menuTools->addAction(tr("&Download Manager"), this, SLOT(showDownloadManager()))->setShortcut(QKeySequence("Ctrl+Y"));
m_menuTools->addAction(tr("&Cookies Manager"), this, SLOT(showCookieManager()));
Expand All @@ -497,6 +502,8 @@ void QupZilla::setupMenu()
#if !defined(QZ_WS_X11) && !defined(Q_OS_MAC)
m_menuTools->addAction(m_actionPreferences);
#endif
connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu()));
connect(m_menuTools, SIGNAL(aboutToHide()), this, SLOT(aboutToHideToolsMenu()));

/*************
* Help Menu *
Expand Down Expand Up @@ -985,11 +992,18 @@ void QupZilla::aboutToShowViewMenu()
m_actionShowStatusbar->setChecked(statusBar()->isVisible());
m_actionShowBookmarksToolbar->setChecked(m_bookmarksToolbar->isVisible());

m_actionPageSource->setEnabled(true);

#if QTWEBKIT_FROM_2_3
m_actionCaretBrowsing->setChecked(mApp->webSettings()->testAttribute(QWebSettings::CaretBrowsingEnabled));
#endif
}

void QupZilla::aboutToHideViewMenu()
{
m_actionPageSource->setEnabled(false);
}

void QupZilla::aboutToShowEditMenu()
{
WebView* view = weView();
Expand All @@ -1014,6 +1028,16 @@ void QupZilla::aboutToHideEditMenu()
m_actionPreferences->setEnabled(true);
}

void QupZilla::aboutToShowToolsMenu()
{
m_actionPageInfo->setEnabled(true);
}

void QupZilla::aboutToHideToolsMenu()
{
m_actionPageInfo->setEnabled(false);
}

void QupZilla::aboutToShowEncodingMenu()
{
m_menuEncoding->clear();
Expand Down Expand Up @@ -1742,6 +1766,20 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
}
break;

case Qt::Key_I:
if (event->modifiers() == Qt::ControlModifier) {
showPageInfo();
event->accept();
}
break;

case Qt::Key_U:
if (event->modifiers() == Qt::ControlModifier) {
showSource();
event->accept();
}
break;

case Qt::Key_1:
number = 1;
break;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/app/qupzilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ private slots:
void aboutToShowClosedTabsMenu();
void aboutToShowBookmarksMenu();
void aboutToShowViewMenu();
void aboutToHideViewMenu();
void aboutToShowEditMenu();
void aboutToHideEditMenu();
void aboutToShowToolsMenu();
void aboutToHideToolsMenu();
void aboutToShowEncodingMenu();

void searchOnPage();
Expand Down Expand Up @@ -270,6 +273,8 @@ private slots:
QAction* m_actionReload;
QAction* m_actionCaretBrowsing;
QAction* m_actionRestoreTab;
QAction* m_actionPageInfo;
QAction* m_actionPageSource;

QLabel* m_privateBrowsing;
AdBlockIcon* m_adblockIcon;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/sidebar/sidebar.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2010-2012 David Rosca <[email protected]>
* Copyright (C) 2010-2013 David Rosca <[email protected]>
*
* 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
Expand Down Expand Up @@ -126,7 +126,7 @@ void SideBarManager::refreshMenu()
m_menu->clear();
QAction* act = m_menu->addAction(SideBar::tr("Bookmarks"), this, SLOT(slotShowSideBar()));
act->setCheckable(true);
act->setShortcut(QKeySequence("Ctrl+B"));
act->setShortcut(QKeySequence("Ctrl+Shift+B"));
act->setData("Bookmarks");

act = m_menu->addAction(SideBar::tr("History"), this, SLOT(slotShowSideBar()));
Expand Down
2 changes: 2 additions & 0 deletions src/lib/webview/webview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ WebView::WebView(QWidget* parent)
// Zoom levels same as in firefox
m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300;

#if QTWEBKIT_TO_2_3
installEventFilter(this);
#endif
}

QIcon WebView::icon() const
Expand Down

0 comments on commit 32f69c8

Please sign in to comment.