+void DolphinMainWindow::createToolBarMenuButton()
+{
+ if (m_toolBarSpacer && m_openToolBarMenuButton) {
+ return;
+ }
+ Q_ASSERT(!m_toolBarSpacer);
+ Q_ASSERT(!m_openToolBarMenuButton);
+
+ m_toolBarSpacer = new QWidget(this);
+ m_toolBarSpacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+
+ m_openToolBarMenuButton = new QToolButton(this);
+ m_openToolBarMenuButton->setIcon(KIcon("configure"));
+ m_openToolBarMenuButton->setPopupMode(QToolButton::InstantPopup);
+ m_openToolBarMenuButton->setToolTip(i18nc("@info:tooltip", "Configure and control Dolphin"));
+
+ KMenu* toolBarMenu = new ToolBarMenu(m_openToolBarMenuButton);
+ connect(toolBarMenu, SIGNAL(aboutToShow()), this, SLOT(updateToolBarMenu()));
+
+ m_openToolBarMenuButton->setMenu(toolBarMenu);
+
+ toolBar()->addWidget(m_toolBarSpacer);
+ toolBar()->addWidget(m_openToolBarMenuButton);
+ connect(toolBar(), SIGNAL(iconSizeChanged(QSize)), this, SLOT(slotToolBarIconSizeChanged(QSize)));
+
+ // 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_toolBarSpacer, SIGNAL(destroyed()), this, SLOT(slotToolBarSpacerDeleted()));
+ connect(m_openToolBarMenuButton, SIGNAL(destroyed()), this, SLOT(slotToolBarMenuButtonDeleted()));
+ m_updateToolBarTimer = new QTimer(this);
+ m_updateToolBarTimer->setInterval(500);
+ connect(m_updateToolBarTimer, SIGNAL(timeout()), this, SLOT(updateToolBar()));
+}
+
+void DolphinMainWindow::deleteToolBarMenuButton()
+{
+ delete m_toolBarSpacer;
+ m_toolBarSpacer = 0;
+
+ delete m_openToolBarMenuButton;
+ m_openToolBarMenuButton = 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)
+{
+ KMenu* tabsMenu = m_recentTabsMenu->menu();
+
+ const QString primaryPath = m_viewTab[index].primaryView->url().path();
+ const QString iconName = KMimeType::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(KIcon(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->refresh();
+ if (m_viewTab[i].secondaryView) {
+ m_viewTab[i].secondaryView->refresh();
+ }
+ }
+
+ 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();
+ }
+ }
+}
+