1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 09:32:12 +01:00

Navigating in tabs with Ctrl + PgUp/PgDown.

- closes #331
This commit is contained in:
nowrep 2012-03-22 17:19:10 +01:00
parent c664ea076b
commit 1c270046ec
3 changed files with 37 additions and 12 deletions

View File

@ -1651,13 +1651,29 @@ void QupZilla::keyPressEvent(QKeyEvent* event)
case Qt::Key_Tab:
if (event->modifiers() == Qt::ControlModifier) {
m_tabWidget->createKeyPressEvent(event);
m_tabWidget->nextTab();
event->accept();
}
break;
case Qt::Key_Backtab:
if (event->modifiers() == (Qt::ControlModifier + Qt::ShiftModifier)) {
m_tabWidget->createKeyPressEvent(event);
m_tabWidget->previousTab();
event->accept();
}
break;
case Qt::Key_PageDown:
if (event->modifiers() == Qt::ControlModifier) {
m_tabWidget->nextTab();
event->accept();
}
break;
case Qt::Key_PageUp:
if (event->modifiers() == Qt::ControlModifier) {
m_tabWidget->previousTab();
event->accept();
}
break;

View File

@ -159,11 +159,6 @@ WebTab* TabWidget::weTab(int index)
return qobject_cast<WebTab*>(widget(index));
}
void TabWidget::createKeyPressEvent(QKeyEvent* event)
{
QTabWidget::keyPressEvent(event);
}
void TabWidget::showButtons()
{
m_buttonListTabs->show();
@ -472,6 +467,18 @@ void TabWidget::setTabText(int index, const QString &text)
QTabWidget::setTabText(index, newtext);
}
void TabWidget::nextTab()
{
QKeyEvent fakeEvent(QKeyEvent::KeyPress, Qt::Key_Tab, Qt::ControlModifier);
keyPressEvent(&fakeEvent);
}
void TabWidget::previousTab()
{
QKeyEvent fakeEvent(QKeyEvent::KeyPress, Qt::Key_Backtab, QFlags<Qt::KeyboardModifier>(Qt::ControlModifier + Qt::ShiftModifier));
keyPressEvent(&fakeEvent);
}
void TabWidget::reloadTab(int index)
{
weTab(index)->reload();

View File

@ -69,17 +69,19 @@ public:
void setTabIcon(int index, const QIcon &icon);
void setTabText(int index, const QString &text);
inline TabBar* getTabBar() { return m_tabBar; }
inline ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }
void nextTab();
void previousTab();
void showTabBar();
TabBar* getTabBar() { return m_tabBar; }
ClosedTabsManager* closedTabsManager() { return m_closedTabsManager; }
bool canRestoreTab();
QList<WebTab*> allTabs(bool withPinned = true);
QStackedWidget* locationBars() { return m_locationBars; }
ToolButton* buttonListTabs() { return m_buttonListTabs; }
AddTabButton* buttonAddTab() { return m_buttonAddTab; }
void createKeyPressEvent(QKeyEvent* event);
void showTabBar();
void disconnectObjects();
signals: