From 681a611588781734d45395d76ec802c0a2117be3 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Tue, 13 Sep 2011 17:10:30 +0200 Subject: Fix close & session First, I'm really sorry for this bad commit ('git' talking..). The fact is that the 3 bugs fixed here were found chained playing with close code. Here it is the report: - fix close window (it now really appears on multiple window closing) - fix saveSession (saving one call for each site loaded and storing better information): saveSession is now called on loadFinished - clean up some compilation warnings --- src/mainwindow.cpp | 57 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d1650f36..ebf8d676 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -274,8 +274,8 @@ void MainWindow::postLaunch() // Ctrl + wheel handling connect(this->currentTab()->view(), SIGNAL(zoomChanged(int)), m_zoomBar, SLOT(setValue(int))); - // Save session when last window is closed - connect(this, SIGNAL(lastWindowClosed()), rApp->sessionManager(), SLOT(saveSession())); + // Save session on window closing + connect(this, SIGNAL(windowClosing()), rApp->sessionManager(), SLOT(saveSession())); // setting up toolbars to NOT have context menu enabled setContextMenuPolicy(Qt::DefaultContextMenu); @@ -295,6 +295,7 @@ QSize MainWindow::sizeHint() const return size; } + void MainWindow::changeWindowIcon(int index) { if (ReKonfig::useFavicon()) @@ -305,6 +306,7 @@ void MainWindow::changeWindowIcon(int index) } } + void MainWindow::setupActions() { // this let shortcuts work.. @@ -322,7 +324,7 @@ void MainWindow::setupActions() KStandardAction::open(this, SLOT(fileOpen()), actionCollection()); KStandardAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); KStandardAction::print(this, SLOT(printRequested()), actionCollection()); - KStandardAction::quit(rApp, SLOT(quit()), actionCollection()); + KStandardAction::quit(rApp, SLOT(queryQuit()), actionCollection()); a = KStandardAction::find(m_findBar, SLOT(show()), actionCollection()); KShortcut findShortcut = KStandardShortcut::find(); @@ -1290,6 +1292,7 @@ void MainWindow::clearPrivateData() dialog->deleteLater(); } + void MainWindow::aboutToShowBackMenu() { m_historyBackMenu->clear(); @@ -1403,6 +1406,7 @@ void MainWindow::openActionUrl(QAction *action) history->goToItem(history->itemAt(index)); } + void MainWindow::openActionTab(QAction* action) { int index = action->data().toInt(); @@ -1481,46 +1485,6 @@ void MainWindow::enableNetworkAnalysis(bool b) } -bool MainWindow::queryClose() -{ - // this should fux bug 240432 - if (rApp->sessionSaving()) - return true; - - // smooth private browsing mode - if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled)) - return true; - - if (rApp->mainWindowList().count() > 1) - { - int answer = KMessageBox::questionYesNoCancel( - this, - i18n("Wanna close the window or the whole app?"), - i18n("Application/Window closing..."), - KGuiItem(i18n("C&lose Current Window"), KIcon("window-close")), - KStandardGuiItem::quit(), - KStandardGuiItem::cancel(), - "confirmClosingMultipleWindows" - ); - - switch (answer) - { - case KMessageBox::Yes: - return true; - - case KMessageBox::No: - rApp->quit(); - return true; - - default: - return false; - } - } - emit lastWindowClosed(); - return true; -} - - void MainWindow::saveNewToolbarConfig() { KXmlGuiWindow::saveNewToolbarConfig(); @@ -1586,3 +1550,10 @@ void MainWindow::setEditable(bool on) { currentTab()->page()->setContentEditable(on); } + + +bool MainWindow::close() +{ + emit windowClosing(); + return KMainWindow::close(); +} -- cgit v1.2.1