Reuse an existing action to toggle sidebar visibility

BUG: 468317
remotes/origin/work/sune/signature-info-devirtualization
Eugene Popov 3 years ago committed by Albert Astals Cid
parent 0da9a8a1c4
commit a25e37e6f7
  1. 22
      shell/shell.cpp
  2. 5
      shell/shell.rc

@ -537,12 +537,6 @@ void Shell::setupActions()
m_undoCloseTab->setEnabled(false); m_undoCloseTab->setEnabled(false);
connect(m_undoCloseTab, &QAction::triggered, this, &Shell::undoCloseTab); connect(m_undoCloseTab, &QAction::triggered, this, &Shell::undoCloseTab);
m_showSidebarAction = actionCollection()->addAction(QStringLiteral("okular_show_sidebar"));
m_showSidebarAction->setCheckable(true);
m_showSidebarAction->setIcon(QIcon::fromTheme(QStringLiteral("sidebar-show-symbolic")));
m_showSidebarAction->setText(i18n("Show Sidebar"));
connect(m_showSidebarAction, &QAction::triggered, m_sidebar, &Sidebar::setVisible);
m_lockSidebarAction = actionCollection()->addAction(QStringLiteral("okular_lock_sidebar")); m_lockSidebarAction = actionCollection()->addAction(QStringLiteral("okular_lock_sidebar"));
m_lockSidebarAction->setCheckable(true); m_lockSidebarAction->setCheckable(true);
m_lockSidebarAction->setIcon(QIcon::fromTheme(QStringLiteral("lock"))); m_lockSidebarAction->setIcon(QIcon::fromTheme(QStringLiteral("lock")));
@ -802,6 +796,10 @@ bool Shell::queryClose()
void Shell::setActiveTab(int tab) void Shell::setActiveTab(int tab)
{ {
if (m_showSidebarAction) {
m_showSidebarAction->disconnect();
}
m_tabWidget->setCurrentIndex(tab); m_tabWidget->setCurrentIndex(tab);
// NOTE : createGUI(...) breaks the visibility of the sidebar, so we need // NOTE : createGUI(...) breaks the visibility of the sidebar, so we need
@ -822,6 +820,12 @@ void Shell::setActiveTab(int tab)
} }
m_sidebar->setCurrentWidget(sideContainer); m_sidebar->setCurrentWidget(sideContainer);
m_showSidebarAction = m_tabs[tab].part->actionCollection()->action(QStringLiteral("show_leftpanel"));
Q_ASSERT(m_showSidebarAction);
m_showSidebarAction->disconnect();
m_showSidebarAction->setChecked(m_sidebar->isVisibleTo(this));
connect(m_showSidebarAction, &QAction::triggered, m_sidebar, &Sidebar::setVisible);
m_printAction->setEnabled(m_tabs[tab].printEnabled); m_printAction->setEnabled(m_tabs[tab].printEnabled);
m_closeAction->setEnabled(m_tabs[tab].closeEnabled); m_closeAction->setEnabled(m_tabs[tab].closeEnabled);
} }
@ -942,12 +946,6 @@ void Shell::connectPart(const KParts::ReadWritePart *part)
// Otherwise the QSize,QSize gets turned into QSize, QSize that is not normalized signals and is slightly slower // Otherwise the QSize,QSize gets turned into QSize, QSize that is not normalized signals and is slightly slower
connect(part, SIGNAL(fitWindowToPage(QSize,QSize)), this, SLOT(slotFitWindowToPage(QSize,QSize))); // clazy:exclude=old-style-connect connect(part, SIGNAL(fitWindowToPage(QSize,QSize)), this, SLOT(slotFitWindowToPage(QSize,QSize))); // clazy:exclude=old-style-connect
// clang-format on // clang-format on
// since sidebar is now docked to main window, we use another action
// to show/hide it, so we should hide a similar KPart's action
if (QAction *action = part->actionCollection()->action(QStringLiteral("show_leftpanel"))) {
action->setVisible(false);
}
} }
void Shell::print() void Shell::print()

@ -1,6 +1,6 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd"> <!DOCTYPE gui SYSTEM "kpartgui.dtd">
<gui version="10" name="okular_shell" > <gui version="11" name="okular_shell" >
<MenuBar> <MenuBar>
<Menu name="file" > <Menu name="file" >
<DefineGroup append="open_merge" name="file_open" /> <DefineGroup append="open_merge" name="file_open" />
@ -13,7 +13,6 @@
</Menu--> </Menu-->
<Menu name="settings" > <Menu name="settings" >
<DefineGroup append="show_merge" name="show_merge" /> <DefineGroup append="show_merge" name="show_merge" />
<Action name="okular_show_sidebar" append="show_merge" />
<DefineGroup append="configure_merge" name="configure_merge" /> <DefineGroup append="configure_merge" name="configure_merge" />
</Menu> </Menu>
<Merge/> <Merge/>
@ -22,12 +21,10 @@
</Menu> </Menu>
</MenuBar> </MenuBar>
<ToolBar noMerge="1" name="mainToolBar" > <ToolBar noMerge="1" name="mainToolBar" >
<Action name="okular_show_sidebar" />
<text>Main Toolbar</text> <text>Main Toolbar</text>
<!--Action name="file_open_recent" /--> <!--Action name="file_open_recent" /-->
<!--Action name="file_print" /--> <!--Action name="file_print" /-->
</ToolBar> </ToolBar>
<ActionProperties scheme="Default"> <ActionProperties scheme="Default">
<Action priority="0" name="okular_show_sidebar"/>
</ActionProperties> </ActionProperties>
</gui> </gui>

Loading…
Cancel
Save