+void DolphinMainWindow::createControlButton()
+{
+ if (m_controlButton) {
+ return;
+ }
+ Q_ASSERT(!m_controlButton);
+
+ m_controlButton = new QToolButton(this);
+ m_controlButton->setIcon(QIcon::fromTheme("applications-system"));
+ m_controlButton->setText(i18nc("@action", "Control"));
+ m_controlButton->setPopupMode(QToolButton::InstantPopup);
+ m_controlButton->setToolButtonStyle(toolBar()->toolButtonStyle());
+
+ KMenu* controlMenu = new KMenu(m_controlButton);
+ connect(controlMenu, &KMenu::aboutToShow, this, &DolphinMainWindow::updateControlMenu);
+
+ m_controlButton->setMenu(controlMenu);
+
+ toolBar()->addWidget(m_controlButton);
+ connect(toolBar(), &KToolBar::iconSizeChanged,
+ m_controlButton, &QToolButton::setIconSize);
+ connect(toolBar(), &KToolBar::toolButtonStyleChanged,
+ m_controlButton, &QToolButton::setToolButtonStyle);
+
+ // The added widgets are owned by the toolbar and may get deleted when e.g. the toolbar
+ // gets edited. In this case we must add them again. The adding is done asynchronously by
+ // m_updateToolBarTimer.
+ connect(m_controlButton, &QToolButton::destroyed, this, &DolphinMainWindow::slotControlButtonDeleted);
+ m_updateToolBarTimer = new QTimer(this);
+ m_updateToolBarTimer->setInterval(500);
+ connect(m_updateToolBarTimer, &QTimer::timeout, this, &DolphinMainWindow::updateToolBar);
+}
+
+void DolphinMainWindow::deleteControlButton()
+{
+ delete m_controlButton;
+ m_controlButton = 0;
+
+ delete m_updateToolBarTimer;
+ m_updateToolBarTimer = 0;
+}
+
+bool DolphinMainWindow::addActionToMenu(QAction* action, KMenu* menu)
+{
+ Q_ASSERT(action);
+ Q_ASSERT(menu);
+
+ const KToolBar* toolBarWidget = toolBar();
+ foreach (const QWidget* widget, action->associatedWidgets()) {
+ if (widget == toolBarWidget) {
+ return false;
+ }
+ }
+
+ menu->addAction(action);
+ return true;
+}
+
+void DolphinMainWindow::rememberClosedTab(int index)
+{
+ QMenu* tabsMenu = m_recentTabsMenu->menu();
+
+ const QString primaryPath = m_viewTab[index].primaryView->url().path();
+ const QString iconName = KIO::iconNameForUrl(primaryPath);
+
+ QAction* action = new QAction(squeezedText(primaryPath), tabsMenu);
+
+ ClosedTab closedTab;
+ closedTab.primaryUrl = m_viewTab[index].primaryView->url();
+
+ if (m_viewTab[index].secondaryView) {
+ closedTab.secondaryUrl = m_viewTab[index].secondaryView->url();
+ closedTab.isSplit = true;
+ } else {
+ closedTab.isSplit = false;
+ }
+
+ action->setData(QVariant::fromValue(closedTab));
+ action->setIcon(QIcon::fromTheme(iconName));
+
+ // add the closed tab menu entry after the separator and
+ // "Empty Recently Closed Tabs" entry
+ if (tabsMenu->actions().size() == 2) {
+ tabsMenu->addAction(action);
+ } else {
+ tabsMenu->insertAction(tabsMenu->actions().at(2), action);
+ }
+
+ // assure that only up to 8 closed tabs are shown in the menu
+ if (tabsMenu->actions().size() > 8) {
+ tabsMenu->removeAction(tabsMenu->actions().last());
+ }
+ actionCollection()->action("closed_tabs")->setEnabled(true);
+ KAcceleratorManager::manage(tabsMenu);
+}
+
+void DolphinMainWindow::refreshViews()
+{
+ Q_ASSERT(m_viewTab[m_tabIndex].primaryView);
+
+ // remember the current active view, as because of
+ // the refreshing the active view might change to
+ // the secondary view
+ DolphinViewContainer* activeViewContainer = m_activeViewContainer;
+
+ const int tabCount = m_viewTab.count();
+ for (int i = 0; i < tabCount; ++i) {
+ m_viewTab[i].primaryView->readSettings();
+ if (m_viewTab[i].secondaryView) {
+ m_viewTab[i].secondaryView->readSettings();
+ }
+ }
+
+ setActiveViewContainer(activeViewContainer);
+
+ if (GeneralSettings::modifiedStartupSettings()) {
+ // The startup settings have been changed by the user (see bug #254947).
+ // Synchronize the split-view setting with the active view:
+ const bool splitView = GeneralSettings::splitView();
+ const ViewTab& activeTab = m_viewTab[m_tabIndex];
+ const bool toggle = ( splitView && !activeTab.secondaryView)
+ || (!splitView && activeTab.secondaryView);
+ if (toggle) {
+ toggleSplitView();
+ }
+ }
+
+ emit settingsChanged();
+}
+