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

MainMenu: Fix shortcuts for toggling sidebars

This commit is contained in:
David Rosca 2014-09-25 17:36:51 +02:00
parent 5c20fdfe82
commit 01b4fd971f
5 changed files with 17 additions and 13 deletions

View File

@ -949,6 +949,9 @@ void BrowserWindow::restoreWindowState(const RestoreManager::WindowData &d)
void BrowserWindow::createToolbarsMenu(QMenu* menu) void BrowserWindow::createToolbarsMenu(QMenu* menu)
{ {
removeActions(menu->actions());
menu->clear();
QAction* action; QAction* action;
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
@ -970,6 +973,8 @@ void BrowserWindow::createToolbarsMenu(QMenu* menu)
action = menu->addAction(tr("&Tabs on Top"), this, SLOT(toggleTabsOnTop(bool))); action = menu->addAction(tr("&Tabs on Top"), this, SLOT(toggleTabsOnTop(bool)));
action->setCheckable(true); action->setCheckable(true);
action->setChecked(qzSettings->tabsOnTop); action->setChecked(qzSettings->tabsOnTop);
addActions(menu->actions());
} }
void BrowserWindow::createSidebarsMenu(QMenu* menu) void BrowserWindow::createSidebarsMenu(QMenu* menu)
@ -1018,6 +1023,13 @@ void BrowserWindow::createEncodingMenu(QMenu* menu)
createEncodingSubMenu(tr("Other"), otherCodecs, menu); createEncodingSubMenu(tr("Other"), otherCodecs, menu);
} }
void BrowserWindow::removeActions(const QList<QAction *> &actions)
{
foreach (QAction *action, actions) {
removeAction(action);
}
}
void BrowserWindow::addTab() void BrowserWindow::addTab()
{ {
m_tabWidget->addView(QUrl(), Qz::NT_SelectedNewEmptyTab, true); m_tabWidget->addView(QUrl(), Qz::NT_SelectedNewEmptyTab, true);

View File

@ -82,6 +82,8 @@ public:
void createSidebarsMenu(QMenu* menu); void createSidebarsMenu(QMenu* menu);
void createEncodingMenu(QMenu* menu); void createEncodingMenu(QMenu* menu);
void removeActions(const QList<QAction*> &actions);
SideBar* addSideBar(); SideBar* addSideBar();
QByteArray saveState(int version = 0) const; QByteArray saveState(int version = 0) const;

View File

@ -465,7 +465,6 @@ void MainMenu::aboutToShowSidebarsMenu()
Q_ASSERT(menu); Q_ASSERT(menu);
if (m_window) { if (m_window) {
menu->clear();
m_window->createSidebarsMenu(menu); m_window->createSidebarsMenu(menu);
} }
} }

View File

@ -93,6 +93,9 @@ SideBarManager::SideBarManager(BrowserWindow* parent)
void SideBarManager::createMenu(QMenu* menu) void SideBarManager::createMenu(QMenu* menu)
{ {
m_window->removeActions(menu->actions());
menu->clear();
QAction* act = menu->addAction(SideBar::tr("Bookmarks"), this, SLOT(slotShowSideBar())); QAction* act = menu->addAction(SideBar::tr("Bookmarks"), this, SLOT(slotShowSideBar()));
act->setCheckable(true); act->setCheckable(true);
act->setShortcut(QKeySequence("Ctrl+Shift+B")); act->setShortcut(QKeySequence("Ctrl+Shift+B"));
@ -116,9 +119,6 @@ void SideBarManager::createMenu(QMenu* menu)
} }
m_window->addActions(menu->actions()); m_window->addActions(menu->actions());
// Menu is only valid until hidden
connect(menu, SIGNAL(aboutToHide()), this, SLOT(clearMenu()));
} }
void SideBarManager::addSidebar(const QString &id, SideBarInterface* interface) void SideBarManager::addSidebar(const QString &id, SideBarInterface* interface)
@ -142,14 +142,6 @@ void SideBarManager::slotShowSideBar()
} }
} }
void SideBarManager::clearMenu()
{
QMenu* menu = qobject_cast<QMenu*>(sender());
Q_ASSERT(menu);
menu->clear();
}
void SideBarManager::showSideBar(const QString &id, bool toggle) void SideBarManager::showSideBar(const QString &id, bool toggle)
{ {
if (id == QLatin1String("None")) { if (id == QLatin1String("None")) {

View File

@ -72,7 +72,6 @@ public:
private slots: private slots:
void slotShowSideBar(); void slotShowSideBar();
void clearMenu();
private: private:
BrowserWindow* m_window; BrowserWindow* m_window;