From b87d73147b681d548c11785004c21e469c026391 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sat, 22 Sep 2012 12:36:01 +0200 Subject: Re-enable fullscreen capabilities --- src/tabwindow/tabbar.cpp | 5 +++++ src/tabwindow/tabwindow.cpp | 11 +++++++++++ src/tabwindow/tabwindow.h | 2 ++ src/webtab/webview.cpp | 27 ++++++--------------------- src/webwindow/webwindow.cpp | 44 +++++++++++++++++++++++++++++++++----------- src/webwindow/webwindow.h | 6 +++++- 6 files changed, 62 insertions(+), 33 deletions(-) diff --git a/src/tabwindow/tabbar.cpp b/src/tabwindow/tabbar.cpp index 18393cf9..a1e69745 100644 --- a/src/tabwindow/tabbar.cpp +++ b/src/tabwindow/tabbar.cpp @@ -102,6 +102,11 @@ QSize TabBar::tabSizeHint(int index) const int h = size().height(); + // this because it may happen sometimes (eg: exiting fullscreen) + // that tabbar height is set to ZERO. And this is NOT good... + if (h == 0) + h = 30; + QSize ts = QSize(w, h); return ts; } diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp index ba355e51..297653e8 100644 --- a/src/tabwindow/tabwindow.cpp +++ b/src/tabwindow/tabwindow.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -146,6 +147,8 @@ WebWindow *TabWindow::prepareNewTab(WebPage *page) connect(tab, SIGNAL(pageCreated(WebPage *)), this, SLOT(pageCreated(WebPage *))); + connect(tab, SIGNAL(setFullScreen(bool)), this, SLOT(setFullScreen(bool))); + return tab; } @@ -490,3 +493,11 @@ void TabWindow::restoreClosedTab(int i) // just to get sure... m_recentlyClosedTabs.removeAll(history); } + + +void TabWindow::setFullScreen(bool makeFullScreen) +{ + tabBar()->setVisible(!makeFullScreen); + _addTabButton->setVisible(!makeFullScreen); + KToggleFullScreenAction::setFullScreen(this, makeFullScreen); +} diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h index 750cac5f..882ca4e9 100644 --- a/src/tabwindow/tabwindow.h +++ b/src/tabwindow/tabwindow.h @@ -100,6 +100,8 @@ private Q_SLOTS: void reloadAllTabs(); void restoreClosedTab(int i); + void setFullScreen(bool); + private: // the new tab button QToolButton *_addTabButton; diff --git a/src/webtab/webview.cpp b/src/webtab/webview.cpp index 5cb5e81d..2ac68bf3 100644 --- a/src/webtab/webview.cpp +++ b/src/webtab/webview.cpp @@ -345,11 +345,10 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu.addAction(webwin->actionByName("page_source")); menu.addAction(inspectAction); - if (isFullScreen()) - { - menu.addSeparator(); - menu.addAction(webwin->actionByName("fullscreen")); - } + // we need to show everytime this because we cannot communicate with the tabwindow. + // We are NOT sure it exists.. + menu.addSeparator(); + menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::FullScreen))); } // LINK ACTIONS ------------------------------------------------------------------- @@ -472,7 +471,8 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) KService::Ptr defaultEngine = SearchEngine::defaultEngine(); if (defaultEngine) // check if a default engine is set { - a = new KAction(i18nc("Search selected text with the default search engine", "Search with %1", defaultEngine->name()), this); + a = new KAction(i18nc("Search selected text with the default search engine", "Search with %1", + defaultEngine->name()), this); a->setIcon(IconManager::self()->iconForUrl(SearchEngine::buildQuery(defaultEngine, ""))); a->setData(defaultEngine->entryPath()); connect(a, SIGNAL(triggered(bool)), this, SLOT(search())); @@ -622,21 +622,6 @@ void WebView::mouseMoveEvent(QMouseEvent *event) return; } - WebTab *tab = qobject_cast(parent()); - WebWindow *webwin = tab->webWindow(); - if (webwin->isFullScreen()) - { - // FIXME -// if (event->pos().y() >= 0 && event->pos().y() <= 4) -// { -// webwin->setWidgetsVisible(true); -// } -// else -// { -// if (!webwin->urlBar()->hasFocus()) -// webwin->setWidgetsVisible(false); -// } - } KWebView::mouseMoveEvent(event); } diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp index dc0bf0bd..fe150504 100644 --- a/src/webwindow/webwindow.cpp +++ b/src/webwindow/webwindow.cpp @@ -57,8 +57,8 @@ #include #include #include -#include #include +#include #include #include @@ -103,7 +103,8 @@ WebWindow::WebWindow(QWidget *parent, WebPage *pg) if (ReKonfig::showBookmarksToolbar()) { - _bookmarksBar = qobject_cast(RekonqFactory::createWidget(QL1S("bookmarkToolBar"), this, actionCollection())); + _bookmarksBar = qobject_cast(RekonqFactory::createWidget(QL1S("bookmarkToolBar"), + this, actionCollection())); BookmarkManager::self()->registerBookmarkBar(_bookmarksBar.data()); l->addWidget(_bookmarksBar.data()); @@ -215,11 +216,12 @@ void WebWindow::setupActions() KShortcut findShortcut = KStandardShortcut::find(); a->setShortcut(findShortcut); - a = KStandardAction::fullScreen(this, SLOT(viewFullScreen(bool)), this, actionCollection()); + a = KStandardAction::fullScreen(this, SLOT(setWidgetsHidden(bool)), this, actionCollection()); KShortcut fullScreenShortcut = KStandardShortcut::fullScreen(); fullScreenShortcut.setAlternate(Qt::Key_F11); a->setShortcut(fullScreenShortcut); - + connect(a, SIGNAL(toggled(bool)), this, SIGNAL(setFullScreen(bool))); + a = KStandardAction::redisplay(_tab->view(), SLOT(reload()), actionCollection()); a->setText(i18n("Reload")); KShortcut reloadShortcut = KStandardShortcut::reload(); @@ -756,10 +758,6 @@ void WebWindow::fileSaveAs() void WebWindow::openLocation() { - if (isFullScreen()) - { - _mainToolBar->show(); - } _bar->selectAll(); _bar->setFocus(); } @@ -795,10 +793,34 @@ void WebWindow::viewPageSource() } -void WebWindow::viewFullScreen(bool makeFullScreen) +void WebWindow::setWidgetsHidden(bool hide) { -// FIXME setWidgetsVisible(!makeFullScreen); - KToggleFullScreenAction::setFullScreen(this, makeFullScreen); + // state flags + static bool bookmarksToolBarFlag = false; + + if (hide) + { + // save current state, if in windowed mode + if (!_bookmarksBar.isNull()) + { + bookmarksToolBarFlag = true; + _bookmarksBar.data()->hide(); + } + + // hide main toolbar + _mainToolBar->hide(); + } + else + { + // show main toolbar + _mainToolBar->show(); + + // restore state of windowed mode + if (!_bookmarksBar.isNull() && bookmarksToolBarFlag) + _bookmarksBar.data()->show(); + } + + emit setFullScreen(hide); } diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h index 5f0eecad..35de3f10 100644 --- a/src/webwindow/webwindow.h +++ b/src/webwindow/webwindow.h @@ -87,6 +87,9 @@ private: void setupActions(); void setupTools(); +public Q_SLOTS: + void setWidgetsHidden(bool hide); + private Q_SLOTS: void webLoadProgress(int); void webLoadStarted(); @@ -115,7 +118,6 @@ private Q_SLOTS: // Tools Menu slots void viewPageSource(); - void viewFullScreen(bool enable); void populateUserAgentMenu(); void setEditable(bool); @@ -132,6 +134,8 @@ Q_SIGNALS: void pageCreated(WebPage *); + void setFullScreen(bool); + private: int _progress; -- cgit v1.2.1