diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/application.cpp | 2 | ||||
-rw-r--r-- | src/findbar.cpp | 15 | ||||
-rw-r--r-- | src/findbar.h | 2 | ||||
-rw-r--r-- | src/mainview.cpp | 10 | ||||
-rw-r--r-- | src/mainwindow.cpp | 92 | ||||
-rw-r--r-- | src/mainwindow.h | 14 | ||||
-rw-r--r-- | src/webtab.cpp | 3 |
8 files changed, 96 insertions, 44 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 55ea5127..04b7bf1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ PROJECT( rekonq ) # Informations to update before to release this package. # rekonq info -SET(REKONQ_VERSION "0.3.34" ) +SET(REKONQ_VERSION "0.3.35" ) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/version.h ) diff --git a/src/application.cpp b/src/application.cpp index cfd4d060..14fd5ce0 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -382,8 +382,8 @@ void Application::loadResolvedUrl(ThreadWeaver::Job *job) if (view) { - view->setFocus(); view->load(url); + view->setFocus(); // we are sure of the url now, let's add it to history // anyway we store here just http sites because local and ftp ones are diff --git a/src/findbar.cpp b/src/findbar.cpp index bd1a5137..9efb9c6a 100644 --- a/src/findbar.cpp +++ b/src/findbar.cpp @@ -143,12 +143,6 @@ void FindBar::show() void FindBar::keyPressEvent(QKeyEvent* event) { - if (event->key() == Qt::Key_Escape) - { - hide(); - m_hideTimer->stop(); - return; - } if (event->key() == Qt::Key_Return && !m_lineEdit->text().isEmpty()) { emit searchString(m_lineEdit->text()); @@ -158,6 +152,7 @@ void FindBar::keyPressEvent(QKeyEvent* event) QWidget::keyPressEvent(event); } + void FindBar::notifyMatch(bool match) { QPalette p = m_lineEdit->palette(); @@ -180,3 +175,11 @@ void FindBar::notifyMatch(bool match) m_lineEdit->setPalette(p); m_hideTimer->start(60000); } + + + +void FindBar::hide() +{ + m_hideTimer->stop(); + QWidget::hide(); +} diff --git a/src/findbar.h b/src/findbar.h index fa369f66..5a41c0bc 100644 --- a/src/findbar.h +++ b/src/findbar.h @@ -56,6 +56,7 @@ public: public slots: void clear(); void show(); + void hide(); void notifyMatch(bool match); protected Q_SLOTS: @@ -68,7 +69,6 @@ private: KLineEdit *m_lineEdit; QCheckBox *m_matchCase; QTimer *m_hideTimer; - }; #endif diff --git a/src/mainview.cpp b/src/mainview.cpp index b26e7466..57185fd2 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -306,9 +306,13 @@ void MainView::currentChanged(int index) emit browserTabLoading(true); else emit browserTabLoading(false); + + // update zoom slider + if(!Application::instance()->mainWindowList().isEmpty()) + Application::instance()->mainWindow()->setZoomSliderFactor(tab->view()->zoomFactor()); // set focus to the current webview - tab->setFocus(); + tab->view()->setFocus(); } @@ -507,8 +511,8 @@ void MainView::closeTab(int index) } removeTab(index); - updateTabBar(); // UI operation: do it ASAP!! - tab->deleteLater(); // webView is scheduled for deletion. + updateTabBar(); // UI operation: do it ASAP!! + tab->deleteLater(); // webView is scheduled for deletion. emit tabsChanged(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e11f6d19..9e6bfb03 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -300,20 +300,20 @@ void MainWindow::setupActions() // ============================= Zoom Actions =================================== - a = new KAction(KIcon("zoom-in"), i18n("&Enlarge Font"), this); + a = new KAction(KIcon("zoom-in"), i18n("&Zoom In"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Plus)); - actionCollection()->addAction(QLatin1String("bigger_font"), a); - connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextBigger())); - - a = new KAction(KIcon("zoom-original"), i18n("&Normal Font"), this); + actionCollection()->addAction(QLatin1String("zoom_in"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomIn())); + + a = new KAction(KIcon("zoom-original"), i18n("&Normal Zoom"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_0)); - actionCollection()->addAction(QLatin1String("normal_font"), a); - connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextNormal())); + actionCollection()->addAction(QLatin1String("zoom_normal"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomNormal())); - a = new KAction(KIcon("zoom-out"), i18n("&Shrink Font"), this); + a = new KAction(KIcon("zoom-out"), i18n("&Zoom Out"), this); a->setShortcut(KShortcut(Qt::CTRL | Qt::Key_Minus)); - actionCollection()->addAction(QLatin1String("smaller_font"), a); - connect(a, SIGNAL(triggered(bool)), this, SLOT(viewTextSmaller())); + actionCollection()->addAction(QLatin1String("zoom_out"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(zoomOut())); // =============================== Tools Actions ================================= a = new KAction(i18n("Page S&ource"), this); @@ -411,12 +411,43 @@ void MainWindow::setupTools() toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::SaveAs))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Print))); toolsMenu->addAction(actionByName(KStandardAction::name(KStandardAction::Find))); - - KActionMenu *fontMenu = new KActionMenu(KIcon("page-zoom"), i18n("Zoom"), this); - fontMenu->addAction(actionByName(QLatin1String("smaller_font"))); - fontMenu->addAction(actionByName(QLatin1String("normal_font"))); - fontMenu->addAction(actionByName(QLatin1String("bigger_font"))); - toolsMenu->addAction(fontMenu); + + + + // setup zoom widget + QWidget *zoomWidget = new QWidget(this); + + QToolButton *zoomOut = new QToolButton(zoomWidget); + zoomOut->setDefaultAction(actionByName(QLatin1String("zoom_out"))); + zoomOut->setAutoRaise(true); + + m_zoomSlider = new QSlider(Qt::Horizontal, zoomWidget); + m_zoomSlider->setTracking(true); + m_zoomSlider->setRange(1, 19); // divide by 10 to obtain a qreal for zoomFactor() + m_zoomSlider->setValue(10); + m_zoomSlider->setPageStep(3); + connect(m_zoomSlider, SIGNAL(valueChanged(int)), this, SLOT(setZoomFactor(int))); + + QToolButton *zoomIn = new QToolButton(zoomWidget); + zoomIn->setDefaultAction(actionByName(QLatin1String("zoom_in"))); + zoomIn->setAutoRaise(true); + + QToolButton *zoomNormal = new QToolButton(zoomWidget); + zoomNormal->setDefaultAction(actionByName(QLatin1String("zoom_normal"))); + zoomNormal->setAutoRaise(true); + + QHBoxLayout* zoomWidgetLayout = new QHBoxLayout(zoomWidget); + zoomWidgetLayout->setSpacing(0); + zoomWidgetLayout->setMargin(0); + zoomWidgetLayout->addWidget(zoomOut); + zoomWidgetLayout->addWidget(m_zoomSlider); + zoomWidgetLayout->addWidget(zoomIn); + zoomWidgetLayout->addWidget(zoomNormal); + + QWidgetAction *zoomAction = new QWidgetAction(this); + zoomAction->setDefaultWidget(zoomWidget); + toolsMenu->addAction(zoomAction); + toolsMenu->addSeparator(); @@ -764,27 +795,31 @@ void MainWindow::findPrevious() } -void MainWindow::viewTextBigger() +void MainWindow::zoomIn() { - if (!currentTab()) - return; - currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() + 0.1); + m_zoomSlider->setValue(m_zoomSlider->value() + 1); } - -void MainWindow::viewTextNormal() +void MainWindow::zoomNormal() { - if (!currentTab()) - return; - currentTab()->view()->setTextSizeMultiplier(1.0); + m_zoomSlider->setValue(10); } +void MainWindow::zoomOut() +{ + m_zoomSlider->setValue(m_zoomSlider->value() - 1); +} -void MainWindow::viewTextSmaller() +void MainWindow::setZoomFactor(int factor) { - if (!currentTab()) + if(!currentTab()) return; - currentTab()->view()->setTextSizeMultiplier(currentTab()->view()->textSizeMultiplier() - 0.1); + currentTab()->view()->setZoomFactor(QVariant(factor).toReal() / 10); +} + +void MainWindow::setZoomSliderFactor(qreal factor) +{ + m_zoomSlider->setValue(factor*10); } @@ -930,6 +965,7 @@ void MainWindow::keyPressEvent(QKeyEvent *event) if (event->key() == Qt::Key_Escape) { m_findBar->hide(); + currentTab()->setFocus(); // give focus to web pages return; } diff --git a/src/mainwindow.h b/src/mainwindow.h index 3a828afe..f7746893 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,6 +43,7 @@ class PreviewSelectorBar;/* ==================================================== // Forward Declarations class QWebFrame; +class QSlider; class KAction; class KPassivePopup; @@ -74,7 +75,9 @@ public: virtual QSize sizeHint() const; virtual KActionCollection *actionCollection () const; void setWidgetsVisible(bool makeFullScreen); - + + void setZoomSliderFactor(qreal factor); + private: void setupActions(); void setupTools(); @@ -127,9 +130,10 @@ private slots: void findPrevious(); // Zoom slots - void viewTextBigger(); - void viewTextNormal(); - void viewTextSmaller(); + void zoomIn(); + void zoomNormal(); + void zoomOut(); + void setZoomFactor(int factor); // File Menu slots void openLocation(); @@ -167,6 +171,8 @@ private: KToolBar *m_mainBar; KToolBar *m_bmBar; + QSlider *m_zoomSlider; + QString m_lastSearch; KPassivePopup *m_popup; diff --git a/src/webtab.cpp b/src/webtab.cpp index b1f2cdfc..b3eb71f0 100644 --- a/src/webtab.cpp +++ b/src/webtab.cpp @@ -64,6 +64,9 @@ WebTab::WebTab(QWidget* parent) , m_view( new WebView(this) ) , m_progress(0) { + // fix focus handling + setFocusProxy( m_view ); + QVBoxLayout* l = new QVBoxLayout(this); l->setMargin(0); l->setSpacing(0); |