diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 130 |
1 files changed, 93 insertions, 37 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1488980f..c56dcf76 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -639,17 +639,23 @@ void MainWindow::preferences() void MainWindow::updateActions() { + bool rekonqPage = currentTab()->page()->isOnRekonqPage(); + kDebug() << "UPDATE ACTIONS: rekonq page = " << rekonqPage; + QAction *historyBackAction = actionByName(KStandardAction::name(KStandardAction::Back)); - historyBackAction->setEnabled(currentTab()->view()->history()->canGoBack()); + if( rekonqPage ) + historyBackAction->setEnabled(true); + else + historyBackAction->setEnabled(currentTab()->view()->history()->canGoBack()); QAction *historyForwardAction = actionByName(KStandardAction::name(KStandardAction::Forward)); historyForwardAction->setEnabled(currentTab()->view()->history()->canGoForward()); - QAction *openClosedTabsAction = actionByName(QLatin1String("open_closed_tabs")); + QAction *openClosedTabsAction = actionByName( QL1S("open_closed_tabs") ); openClosedTabsAction->setEnabled(mainView()->recentlyClosedTabs().size() > 0); // update closed tabs menu - KActionMenu *am = dynamic_cast<KActionMenu *>(actionByName(QLatin1String("closed_tab_menu"))); + KActionMenu *am = dynamic_cast<KActionMenu *>(actionByName( QL1S("closed_tab_menu") )); if (!am) return; @@ -861,16 +867,19 @@ void MainWindow::zoomIn() m_zoomSlider->setValue(m_zoomSlider->value() + 1); } + void MainWindow::zoomNormal() { m_zoomSlider->setValue(10); } + void MainWindow::zoomOut() { m_zoomSlider->setValue(m_zoomSlider->value() - 1); } + void MainWindow::setZoomFactor(int factor) { if (!currentTab()) @@ -878,6 +887,7 @@ void MainWindow::setZoomFactor(int factor) currentTab()->view()->setZoomFactor(QVariant(factor).toReal() / 10); } + void MainWindow::setZoomSliderFactor(qreal factor) { m_zoomSlider->setValue(factor*10); @@ -989,8 +999,8 @@ WebTab *MainWindow::currentTab() const void MainWindow::browserLoading(bool v) { - QAction *stop = actionCollection()->action("stop"); - QAction *reload = actionCollection()->action("view_redisplay"); + QAction *stop = actionCollection()->action( QL1S("stop") ); + QAction *reload = actionCollection()->action( QL1S("view_redisplay") ); if (v) { disconnect(m_stopReloadAction, SIGNAL(triggered(bool)), reload , SIGNAL(triggered(bool))); @@ -1014,56 +1024,68 @@ void MainWindow::browserLoading(bool v) void MainWindow::openPrevious(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers) { QWebHistory *history = currentTab()->view()->history(); - if (history->canGoBack()) + QWebHistoryItem *item = 0; + + if (currentTab()->page()->isOnRekonqPage()) { - QWebHistoryItem *item; - if (currentTab()->view()->page()->isOnRekonqPage()) + item = new QWebHistoryItem(history->currentItem()); + currentTab()->view()->page()->setIsOnRekonqPage(false); + } + else + { + if (history->canGoBack()) { - item = new QWebHistoryItem(history->currentItem()); - currentTab()->view()->page()->setIsOnRekonqPage(false); - } - else item = new QWebHistoryItem(history->backItem()); - - if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) - { - Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab); - } - else - { - history->goToItem(*item); } + } - updateActions(); + if(!item) + return; + + if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) + { + Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab); + } + else + { + history->goToItem(*item); } + updateActions(); } void MainWindow::openNext(Qt::MouseButtons mouseButtons, Qt::KeyboardModifiers keyboardModifiers) { QWebHistory *history = currentTab()->view()->history(); - if (history->canGoForward()) + QWebHistoryItem *item = 0; + + if (currentTab()->view()->page()->isOnRekonqPage()) { - QWebHistoryItem *item; - if (currentTab()->view()->page()->isOnRekonqPage()) + item = new QWebHistoryItem(history->currentItem()); + currentTab()->view()->page()->setIsOnRekonqPage(false); + } + else + { + if (history->canGoForward()) { - item = new QWebHistoryItem(history->currentItem()); - currentTab()->view()->page()->setIsOnRekonqPage(false); - } - else item = new QWebHistoryItem(history->forwardItem()); - - if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) - { - Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab); } - else - { - history->goToItem(*item); - } - updateActions(); } + + if(!item) + return; + + if (mouseButtons == Qt::MidButton || keyboardModifiers == Qt::ControlModifier) + { + Application::instance()->loadUrl(item->url(), Rekonq::SettingOpenTab); + } + else + { + history->goToItem(*item); + } + + updateActions(); } @@ -1377,3 +1399,37 @@ void MainWindow::enableNetworkAnalysis(bool b) currentTab()->page()->enableNetworkAnalyzer(b); m_analyzerPanel->toggle(b); } + + +bool MainWindow::queryClose() +{ + if (m_view->count() > 1) + { + int answer = KMessageBox::questionYesNoCancel( + this, + i18np("Are you sure you want to close the window?\n" "You have 1 tab open", + "Are you sure you want to close the window?\n" "You have %1 tabs open" , + m_view->count()), + i18n("Are you sure you want to close the window?"), + KStandardGuiItem::quit(), + KGuiItem(i18n("C&lose Current Tab"), KIcon("tab-close")), + KStandardGuiItem::cancel(), + "confirmClosingMultipleTabs" + ); + + switch (answer) + { + case KMessageBox::Yes: + // Quit + return true; + + case KMessageBox::No: + // Close only the current tab + m_view->closeTab(); + + default: + return false; + } + } + return true; +} |