diff options
-rw-r--r-- | src/application.cpp | 35 | ||||
-rw-r--r-- | src/application.h | 2 | ||||
-rw-r--r-- | src/mainview.cpp | 19 | ||||
-rw-r--r-- | src/mainview.h | 7 | ||||
-rw-r--r-- | src/mainwindow.cpp | 57 | ||||
-rw-r--r-- | src/mainwindow.h | 5 | ||||
-rw-r--r-- | src/sessionmanager.cpp | 8 | ||||
-rw-r--r-- | src/urlbar/webshortcutwidget.cpp | 4 | ||||
-rw-r--r-- | src/webtab.cpp | 3 |
9 files changed, 67 insertions, 73 deletions
diff --git a/src/application.cpp b/src/application.cpp index b30867bb..2d8cddb2 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -61,6 +61,7 @@ #include <KWindowInfo> #include <KGlobal> #include <KCharsets> +#include <KMessageBox> // Qt Includes #include <QVBoxLayout> @@ -687,3 +688,37 @@ void Application::setPrivateBrowsingMode(bool b) loadUrl(KUrl("about:home"), Rekonq::NewWindow); } } + + +void Application::queryQuit() +{ + if (mainWindowList().count() > 1) + { + int answer = KMessageBox::questionYesNoCancel( + mainWindow(), + 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: + mainWindow()->close(); + return; + + case KMessageBox::No: + break; + + default: + return; + } + } + + // in case of just one window... + quit(); +} diff --git a/src/application.h b/src/application.h index cc9bc433..0c4d3101 100644 --- a/src/application.h +++ b/src/application.h @@ -132,6 +132,8 @@ private slots: // the general place to set private browsing void setPrivateBrowsingMode(bool); + void queryQuit(); + private: QWeakPointer<HistoryManager> m_historyManager; QWeakPointer<BookmarkProvider> m_bookmarkProvider; diff --git a/src/mainview.cpp b/src/mainview.cpp index 6d907ea2..716e8dab 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -93,6 +93,7 @@ MainView::MainView(MainWindow *parent) // current page index changing connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); + connect(this, SIGNAL(currentChanged(int)), rApp->sessionManager(), SLOT(saveSession())); QTimer::singleShot(0, this, SLOT(postLaunch())); } @@ -109,9 +110,6 @@ void MainView::postLaunch() m_recentlyClosedTabs.prepend(tab); } - // Session Manager - connect(this, SIGNAL(tabsChanged()), rApp->sessionManager(), SLOT(saveSession())); - m_addTabButton->setDefaultAction(m_parentWindow->actionByName("new_tab")); m_addTabButton->setAutoRaise(true); @@ -278,8 +276,6 @@ void MainView::currentChanged(int index) tab->view()->setFocus(); tabBar()->resetTabHighlighted(index); - - emit tabsChanged(); } @@ -331,12 +327,6 @@ WebTab *MainView::newWebTab(bool focused) { setCurrentWidget(tab); } - else - { - // if tab is not focused, - // current index doesn't change... - emit tabsChanged(); - } return tab; } @@ -508,11 +498,6 @@ void MainView::closeTab(int index, bool del) { tabToClose->deleteLater(); } - - // if tab was not focused, current index does not change... - if (index != currentIndex()) - emit tabsChanged(); - } void MainView::webViewLoadStarted() @@ -627,8 +612,6 @@ void MainView::webViewUrlChanged(const QUrl &url) } if (ReKonfig::hoveringTabOption() == 2) tabBar()->setTabToolTip(index, webTab(index)->url().toMimeDataString()); - - emit tabsChanged(); } diff --git a/src/mainview.h b/src/mainview.h index ede1d62e..ce17a772 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -106,13 +106,6 @@ public: } Q_SIGNALS: - // tabs change when: - // - current tab change - // - one tab is closed - // - one tab is added - // - one tab is updated (eg: changes url) - void tabsChanged(); - // current tab signals void currentTitle(const QString &url); void showStatusBarMessage(const QString &message, Rekonq::Notify status = Rekonq::Info); 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(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index c2654a93..3144222b 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -115,6 +115,8 @@ public Q_SLOTS: void changeWindowIcon(int index); + bool close(); + Q_SIGNALS: // switching tabs void ctrlTabPressed(); @@ -123,7 +125,7 @@ Q_SIGNALS: void triggerPartPrint(); void triggerPartFind(); - void lastWindowClosed(); + void windowClosing(); protected Q_SLOTS: void saveNewToolbarConfig(); @@ -138,7 +140,6 @@ protected: void moveEvent(QMoveEvent *event); void resizeEvent(QResizeEvent *event); bool event(QEvent *event); - bool queryClose(); void finalizeGUI(KXMLGUIClient *client); private Q_SLOTS: diff --git a/src/sessionmanager.cpp b/src/sessionmanager.cpp index 1377132c..c4697f4b 100644 --- a/src/sessionmanager.cpp +++ b/src/sessionmanager.cpp @@ -58,6 +58,7 @@ void SessionManager::saveSession() return; m_safe = false; + kDebug() << "SAVING SESSION..."; QFile sessionFile(m_sessionFilePath); if (!sessionFile.open(QFile::WriteOnly | QFile::Truncate)) @@ -79,7 +80,7 @@ void SessionManager::saveSession() QDomElement tab = document.createElement("tab"); tab.setAttribute("title", mv->webTab(tabNo)->view()->title()); // redundant, but needed for closedSites() // as there's not way to read out the historyData - tab.setAttribute("url", mv->webTab(tabNo)->view()->url().toString()); + tab.setAttribute("url", mv->webTab(tabNo)->url().url()); // Use WebTab's instead of WebView's url() to fix about links if (mv->tabBar()->currentIndex() == tabNo) { tab.setAttribute("currentTab", 1); @@ -151,6 +152,11 @@ bool SessionManager::restoreSession() QDataStream readingStream(&history, QIODevice::ReadOnly); readingStream >> *(view->history()); + + // Get sure about urls are loaded + KUrl u = KUrl(tab.attribute("url")); + if (u.protocol() == QL1S("about")) + view->load(u); } mv->tabBar()->setCurrentIndex(currentTab); diff --git a/src/urlbar/webshortcutwidget.cpp b/src/urlbar/webshortcutwidget.cpp index 111ff836..4c7ba572 100644 --- a/src/urlbar/webshortcutwidget.cpp +++ b/src/urlbar/webshortcutwidget.cpp @@ -38,8 +38,8 @@ WebShortcutWidget::WebShortcutWidget(QWidget *parent) : QMenu(parent) - , m_nameLineEdit(new QLineEdit(this)) , m_wsLineEdit(new QLineEdit(this)) + , m_nameLineEdit(new QLineEdit(this)) , m_noteLabel(new QLabel(this)) { setAttribute(Qt::WA_DeleteOnClose); @@ -52,7 +52,7 @@ WebShortcutWidget::WebShortcutWidget(QWidget *parent) QLabel *webSearchIcon = new QLabel(this); webSearchIcon->setPixmap(KIcon("edit-web-search").pixmap(32, 32)); - // Title + // Title QLabel *titleLabel = new QLabel(this); titleLabel->setText("<h4>" + i18n("Add Search Engine") + "</h4>"); vLay->addWidget(titleLabel); diff --git a/src/webtab.cpp b/src/webtab.cpp index 39287d28..1eba22a1 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -87,6 +87,9 @@ WebTab::WebTab(QWidget *parent) connect(m_webView, SIGNAL(loadProgress(int)), this, SLOT(updateProgress(int))); connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); connect(m_webView, SIGNAL(titleChanged(const QString &)), this, SIGNAL(titleChanged(const QString &))); + + // Session Manager + connect(m_webView, SIGNAL(loadFinished(bool)), rApp->sessionManager(), SLOT(saveSession())); } |