void WindowsManager::closeWindow(Window *window) { const int index = getWindowIndex(window); if (index < 0) { return; } if (window && !window->isPrivate()) { const WindowHistoryInformation history = window->getContentsWidget()->getHistory(); if (!window->isUrlEmpty() || history.entries.count() > 1) { const SessionWindow information = window->getSession(); if (window->getType() != QLatin1String("web")) { removeStoredUrl(information.getUrl()); } m_closedWindows.prepend(information); emit closedWindowsAvailableChanged(true); } } if (m_tabBar->count() == 1) { window = getWindow(0); if (window) { window->clear(); return; } } m_tabBar->removeTab(index); emit windowRemoved(index); if (m_tabBar->count() < 1) { open(); } }
void WindowsManager::restore(const SessionMainWindow &session) { if (session.windows.isEmpty()) { open(); } else { for (int i = 0; i < session.windows.count(); ++i) { Window *window = new Window(m_isPrivate, NULL, m_mdi); window->setSession(session.windows.at(i)); addWindow(window); } } m_isRestored = true; connect(SessionsManager::getInstance(), SIGNAL(requestedRemoveStoredUrl(QString)), this, SLOT(removeStoredUrl(QString))); connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(setActiveWindow(int))); connect(m_tabBar, SIGNAL(requestedClone(int)), this, SLOT(cloneWindow(int))); connect(m_tabBar, SIGNAL(requestedDetach(int)), this, SLOT(detachWindow(int))); connect(m_tabBar, SIGNAL(requestedPin(int,bool)), this, SLOT(pinWindow(int,bool))); connect(m_tabBar, SIGNAL(requestedClose(int)), this, SLOT(closeWindow(int))); connect(m_tabBar, SIGNAL(requestedCloseOther(int)), this, SLOT(closeOther(int))); setActiveWindow(session.index); }
void WindowsManager::handleWindowClose(Window *window) { const int index = (window ? getWindowIndex(window->getIdentifier()) : -1); if (index < 0) { return; } if (window && !window->isPrivate()) { const WindowHistoryInformation history = window->getContentsWidget()->getHistory(); if (!Utils::isUrlEmpty(window->getUrl()) || history.entries.count() > 1) { Window *nextWindow = getWindowByIndex(index + 1); Window *previousWindow = ((index > 0) ? getWindowByIndex(index - 1) : NULL); ClosedWindow closedWindow; closedWindow.window = window->getSession(); closedWindow.nextWindow = (nextWindow ? nextWindow->getIdentifier() : 0); closedWindow.previousWindow = (previousWindow ? previousWindow->getIdentifier() : 0); if (window->getType() != QLatin1String("web")) { removeStoredUrl(closedWindow.window.getUrl()); } m_closedWindows.prepend(closedWindow); emit closedWindowsAvailableChanged(true); } } const QString lastTabClosingAction = SettingsManager::getValue(QLatin1String("Interface/LastTabClosingAction")).toString(); if (m_mainWindow->getTabBar()->count() == 1) { if (lastTabClosingAction == QLatin1String("closeWindow") || (lastTabClosingAction == QLatin1String("closeWindowIfNotLast") && SessionsManager::getWindows().count() > 1)) { m_mainWindow->triggerAction(ActionsManager::CloseWindowAction); return; } if (lastTabClosingAction == QLatin1String("openTab")) { window = getWindowByIndex(0); if (window) { window->clear(); return; } } else { m_mainWindow->getAction(ActionsManager::CloseTabAction)->setEnabled(false); m_mainWindow->setCurrentWindow(NULL); emit windowTitleChanged(QString()); } } m_mainWindow->getTabBar()->removeTab(index); Action *closePrivateTabsAction = m_mainWindow->getAction(ActionsManager::ClosePrivateTabsAction); if (closePrivateTabsAction->isEnabled() && getWindowCount(true) == 0) { closePrivateTabsAction->setEnabled(false); } emit windowRemoved(window->getIdentifier()); m_windows.remove(window->getIdentifier()); if (m_mainWindow->getTabBar()->count() < 1 && lastTabClosingAction == QLatin1String("openTab")) { open(); } }
void WindowsManager::closeWindow(Window *window) { const int index = getWindowIndex(window); if (index < 0) { return; } if (window && !window->isPrivate()) { const WindowHistoryInformation history = window->getContentsWidget()->getHistory(); if (!window->isUrlEmpty() || history.entries.count() > 1) { const SessionWindow information = window->getSession(); if (window->getType() != QLatin1String("web")) { removeStoredUrl(information.getUrl()); } m_closedWindows.prepend(information); emit closedWindowsAvailableChanged(true); } } const QString lastTabClosingAction = SettingsManager::getValue(QLatin1String("TabBar/LastTabClosingAction")).toString(); if (m_tabBar->count() == 1) { if (lastTabClosingAction == QLatin1String("closeWindow")) { ActionsManager::triggerAction(QLatin1String("CloseWindow"), m_mdi); return; } if (lastTabClosingAction == QLatin1String("openTab")) { window = getWindow(0); if (window) { window->clear(); return; } } else { ActionsManager::getAction(QLatin1String("CloneTab"), m_mdi)->setEnabled(false); emit windowTitleChanged(QString()); } } m_tabBar->removeTab(index); emit windowRemoved(index); if (m_tabBar->count() < 1 && lastTabClosingAction != QLatin1String("doNothing")) { open(); } }
void WindowsManager::restore(const SessionMainWindow &session) { int index = session.index; if (session.windows.isEmpty()) { m_isRestored = true; if (SettingsManager::getValue(QLatin1String("Interface/LastTabClosingAction")).toString() != QLatin1String("doNothing")) { open(); } else { m_mainWindow->setCurrentWindow(NULL); } } else { for (int i = 0; i < session.windows.count(); ++i) { Window *window = new Window(m_isPrivate); window->setSession(session.windows.at(i)); if (index < 0 && session.windows.at(i).state != MinimizedWindowState) { index = i; } addWindow(window, DefaultOpen, -1, session.windows.at(i).geometry, session.windows.at(i).state, session.windows.at(i).isAlwaysOnTop); } } m_isRestored = true; connect(SessionsManager::getInstance(), SIGNAL(requestedRemoveStoredUrl(QString)), this, SLOT(removeStoredUrl(QString))); connect(m_mainWindow->getTabBar(), SIGNAL(currentChanged(int)), this, SLOT(setActiveWindowByIndex(int))); setActiveWindowByIndex(index); m_mainWindow->getWorkspace()->markRestored(); }