From a4b39822a6dd61342266d40e9d89bfb935d91192 Mon Sep 17 00:00:00 2001 From: nowrep Date: Mon, 24 Oct 2011 17:46:45 +0200 Subject: [PATCH] Various small fixes (including fullscreen buttons hiding) When going to fullscreen, add tab button will no longer stay on screen, and also when going back to normal screen, list tabs button will no longer be hidden. --- src/app/mainapplication.cpp | 15 +++++++++------ src/app/mainapplication.h | 2 ++ src/app/qupzilla.cpp | 14 +++++++++++--- src/other/statusbarmessage.cpp | 20 +++++++++++++++++--- src/other/statusbarmessage.h | 6 +++++- src/webview/tabbar.cpp | 26 ++++++++++++++++++++++++++ src/webview/tabbar.h | 6 ++++++ src/webview/tabwidget.cpp | 16 +++++++++++++++- src/webview/tabwidget.h | 2 ++ src/webview/webview.cpp | 5 ++++- 10 files changed, 97 insertions(+), 15 deletions(-) diff --git a/src/app/mainapplication.cpp b/src/app/mainapplication.cpp index 663881ad1..2d04f3d53 100644 --- a/src/app/mainapplication.cpp +++ b/src/app/mainapplication.cpp @@ -64,6 +64,7 @@ MainApplication::MainApplication(const QList &cm , m_isStateChanged(false) , m_isExited(false) , m_isRestoring(false) + , m_databaseConnected(false) { setOverrideCursor(Qt::WaitCursor); #if defined(Q_WS_X11) & !defined(NO_SYSTEM_DATAPATH) @@ -141,9 +142,6 @@ MainApplication::MainApplication(const QList &cm u.checkProfile(); connectDatabase(); -// if (!QDir(m_activeProfil).exists()) -// m_activeProfil=homePath+"profiles/default/"; - QSettings settings2(m_activeProfil+"settings.ini", QSettings::IniFormat); settings2.beginGroup("SessionRestore"); if (settings2.value("isRunning",false).toBool() ) @@ -359,15 +357,20 @@ void MainApplication::makeNewWindow(bool tryRestore, const QUrl &startUrl) void MainApplication::connectDatabase() { + if (m_databaseConnected) + return; + QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); - db.setDatabaseName(m_activeProfil+"browsedata.db"); - if (!QFile::exists(m_activeProfil+"browsedata.db")) { - QFile(DATADIR+"data/default/profiles/default/browsedata.db").copy(m_activeProfil+"browsedata.db"); + db.setDatabaseName(m_activeProfil + "browsedata.db"); + if (!QFile::exists(m_activeProfil + "browsedata.db")) { + QFile(DATADIR + "data/default/profiles/default/browsedata.db").copy(m_activeProfil + "browsedata.db"); + db.setDatabaseName(m_activeProfil + "browsedata.db"); qWarning("Cannot find SQLite database file! Copying and using the defaults!"); } if (!db.open()) qWarning("Cannot open SQLite database! Continuing without database...."); + m_databaseConnected = true; } void MainApplication::translateApp() diff --git a/src/app/mainapplication.h b/src/app/mainapplication.h index 80efdbde2..9daf17dfd 100644 --- a/src/app/mainapplication.h +++ b/src/app/mainapplication.h @@ -142,6 +142,8 @@ private: bool m_isStateChanged; bool m_isExited; bool m_isRestoring; + + bool m_databaseConnected; }; #endif // MAINAPPLICATION_H diff --git a/src/app/qupzilla.cpp b/src/app/qupzilla.cpp index 7e9e55716..4bfee44c2 100644 --- a/src/app/qupzilla.cpp +++ b/src/app/qupzilla.cpp @@ -985,12 +985,14 @@ void QupZilla::showNavigationWithFullscreen() state = !m_navigationBar->isVisible(); else state = !m_tabWidget->getTabBar()->isVisible(); + if (m_navigationVisible) m_navigationBar->setVisible(state); - m_tabWidget->getTabBar()->setVisible(state); + + m_tabWidget->getTabBar()->updateVisibilityWithFullscreen(state); + if (m_bookmarksToolBarVisible) m_bookmarksToolbar->setVisible(state); - m_tabWidget->buttonListTabs()->setVisible(state); } void QupZilla::fullScreen(bool make) @@ -1000,21 +1002,27 @@ void QupZilla::fullScreen(bool make) m_statusBarVisible = statusBar()->isVisible(); m_navigationVisible = m_navigationBar->isVisible(); m_bookmarksToolBarVisible = m_bookmarksToolbar->isVisible(); + setWindowState(windowState() | Qt::WindowFullScreen); + menuBar()->hide(); statusBar()->hide(); bookmarksToolbar()->hide(); m_navigationBar->hide(); - } else { + } + else { setWindowState(windowState() & ~Qt::WindowFullScreen); + menuBar()->setVisible(m_menuBarVisible); statusBar()->setVisible(m_statusBarVisible); m_bookmarksToolbar->setVisible(m_bookmarksToolBarVisible); m_navigationBar->setVisible(m_navigationVisible); } + m_actionShowFullScreen->setChecked(make); m_navigationBar->buttonExitFullscreen()->setVisible(make); m_tabWidget->getTabBar()->setVisible(!make); + emit setWebViewMouseTracking(make); } diff --git a/src/other/statusbarmessage.cpp b/src/other/statusbarmessage.cpp index 46d07810c..32cf2670e 100644 --- a/src/other/statusbarmessage.cpp +++ b/src/other/statusbarmessage.cpp @@ -19,7 +19,10 @@ #include "qupzilla.h" #include "squeezelabelv1.h" -TipLabel::TipLabel(QupZilla* parent) : SqueezeLabelV1(parent) , p_QupZilla(parent) +TipLabel::TipLabel(QupZilla* parent) + : SqueezeLabelV1(parent) + , p_QupZilla(parent) + , m_connected(false) { setWindowFlags(Qt::ToolTip); setForegroundRole(QPalette::ToolTipText); @@ -30,7 +33,17 @@ TipLabel::TipLabel(QupZilla* parent) : SqueezeLabelV1(parent) , p_QupZilla(paren setMargin(2); } -void TipLabel::paintEvent(QPaintEvent *ev) +void TipLabel::show() +{ + if (!m_connected) { + connect(p_QupZilla->tabWidget(), SIGNAL(currentChanged(int)), this, SLOT(hide())); + m_connected = true; + } + + SqueezeLabelV1::show(); +} + +void TipLabel::paintEvent(QPaintEvent* ev) { QStylePainter p(this); QStyleOptionFrame opt; @@ -55,6 +68,7 @@ void StatusBarMessage::showMessage(const QString &message) else { WebView* view = p_QupZilla->weView(); QWebFrame* mainFrame = view->page()->mainFrame(); + m_statusBarText->setParent(view); int horizontalScrollSize = 0; int verticalScrollSize = 0; @@ -77,7 +91,7 @@ void StatusBarMessage::showMessage(const QString &message) if (statusRect.contains(QCursor::pos())) position.setY(position.y() - m_statusBarText->height()); - m_statusBarText->move(view->mapToGlobal(position)); + m_statusBarText->move(/*view->mapToGlobal(*/position/*)*/); m_statusBarText->show(); } } diff --git a/src/other/statusbarmessage.h b/src/other/statusbarmessage.h index c50df8ff7..34f8fdca8 100644 --- a/src/other/statusbarmessage.h +++ b/src/other/statusbarmessage.h @@ -31,10 +31,14 @@ class TipLabel : public SqueezeLabelV1 { public: TipLabel(QupZilla* parent); - void paintEvent(QPaintEvent *ev); + + void show(); private: + void paintEvent(QPaintEvent* ev); + QupZilla* p_QupZilla; + bool m_connected; }; class StatusBarMessage : public QObject diff --git a/src/webview/tabbar.cpp b/src/webview/tabbar.cpp index 2b4022205..c1e7b1b2b 100644 --- a/src/webview/tabbar.cpp +++ b/src/webview/tabbar.cpp @@ -45,6 +45,7 @@ TabBar::TabBar(QupZilla* mainClass, TabWidget* tabWidget) setElideMode(Qt::ElideRight); setTabsClosable(true); setDocumentMode(true); + setFocusPolicy(Qt::NoFocus); loadSettings(); connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(contextMenuRequested(const QPoint &))); @@ -64,6 +65,31 @@ void TabBar::loadSettings() settings.endGroup(); } +void TabBar::updateVisibilityWithFullscreen(bool visible) +{ + if (visible) + emit showButtons(); + else + emit hideButtons(); + + QTabBar::setVisible(visible); +} + +void TabBar::setVisible(bool visible) +{ + if (visible) { + if (p_QupZilla->isFullScreen()) + return; + + emit showButtons(); + } + else { + emit hideButtons(); + } + + QTabBar::setVisible(visible); +} + void TabBar::contextMenuRequested(const QPoint &position) { int index = tabAt(position); diff --git a/src/webview/tabbar.h b/src/webview/tabbar.h index 74f4f2a78..bdda15beb 100644 --- a/src/webview/tabbar.h +++ b/src/webview/tabbar.h @@ -41,6 +41,9 @@ public: void loadSettings(); QSize getTabSizeHint(int index) const { return QTabBar::tabSizeHint(index); } + void setVisible(bool visible); + void updateVisibilityWithFullscreen(bool visible); + signals: void reloadTab(int index); void stopTab(int index); @@ -52,6 +55,9 @@ signals: void moveAddTabButton(int posX); + void showButtons(); + void hideButtons(); + public slots: private slots: diff --git a/src/webview/tabwidget.cpp b/src/webview/tabwidget.cpp index dbc955a13..5a1001fd0 100644 --- a/src/webview/tabwidget.cpp +++ b/src/webview/tabwidget.cpp @@ -121,7 +121,10 @@ TabWidget::TabWidget(QupZilla* mainClass, QWidget* parent) : connect(m_tabBar, SIGNAL(closeAllButCurrent(int)), this, SLOT(closeAllButCurrent(int))); connect(m_tabBar, SIGNAL(duplicateTab(int)), this, SLOT(duplicateTab(int))); connect(m_tabBar, SIGNAL(tabMoved(int,int)), this, SLOT(tabMoved(int,int))); + connect(m_tabBar, SIGNAL(moveAddTabButton(int)), this, SLOT(moveAddTabButton(int))); + connect(m_tabBar, SIGNAL(showButtons()), this, SLOT(showButtons())); + connect(m_tabBar, SIGNAL(hideButtons()), this, SLOT(hideButtons())); m_buttonListTabs = new ToolButton(this); m_buttonListTabs->setObjectName("tabwidget-button-opentabs"); @@ -162,11 +165,22 @@ void TabWidget::resizeEvent(QResizeEvent *e) posit.setY(0); posit.setX(width() - m_buttonListTabs->width()); m_buttonListTabs->move(posit); - m_buttonListTabs->setVisible(getTabBar()->isVisible()); QTabWidget::resizeEvent(e); } +void TabWidget::showButtons() +{ + m_buttonListTabs->show(); + m_buttonAddTab->show(); +} + +void TabWidget::hideButtons() +{ + m_buttonListTabs->hide(); + m_buttonAddTab->hide(); +} + void TabWidget::moveAddTabButton(int posX) { int posY = ( m_tabBar->height() - m_buttonAddTab->height() ) / 2; diff --git a/src/webview/tabwidget.h b/src/webview/tabwidget.h index 6f5de71a1..722d3d45e 100644 --- a/src/webview/tabwidget.h +++ b/src/webview/tabwidget.h @@ -79,6 +79,8 @@ public slots: void clearClosedTabsList(); void moveAddTabButton(int posX); + void showButtons(); + void hideButtons(); private slots: void aboutToShowTabsMenu(); diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index 0505f539c..169a6b691 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -81,6 +81,9 @@ WebView::WebView(QupZilla* mainClass, WebTab* webTab) connect(p_QupZilla, SIGNAL(setWebViewMouseTracking(bool)), this, SLOT(trackMouse(bool))); + //Tracking mouse also on tabs created in fullscreen + trackMouse(p_QupZilla->isFullScreen()); + //Zoom levels same as in firefox m_zoomLevels << 30 << 50 << 67 << 80 << 90 << 100 << 110 << 120 << 133 << 150 << 170 << 200 << 240 << 300; } @@ -263,7 +266,7 @@ void WebView::iconChanged() if (mApp->isClosing()) return; - if (isCurrent()) +// if (isCurrent()) emit siteIconChanged(); if (m_isLoading)