From 7104ccfab5dfefccfa4cb1137f0b7504aa09244f Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Sun, 28 Nov 2010 15:10:21 +0100 Subject: [PATCH] More Symbian tunings. --- adopterwindow.cpp | 61 ++++++++++++++++++++++++++++------------------------- adopterwindow.h | 13 ++++++++---- mainwindow.cpp | 4 ++-- 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/adopterwindow.cpp b/adopterwindow.cpp index e67ae7d..5e9ef64 100644 --- a/adopterwindow.cpp +++ b/adopterwindow.cpp @@ -129,9 +129,7 @@ QAction *AdopterWindow::addToolBarAction(QObject *receiver, if (!toolBar && important) { // Create tool bar if needed toolBar = new QToolBar("", this); - // toolBar->setFixedWidth(QApplication::desktop()-> - // availableGeometry().width()); - toolBar->setFixedHeight(65); + // toolBar->setFixedHeight(63); toolBar->setStyleSheet("margin:0; border:0; padding:0"); toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum); @@ -194,7 +192,8 @@ void AdopterWindow::doGrabVolumeKeys(bool grab) return; } unsigned long val = grab? 1: 0; - Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False); + Atom atom = + XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False); if (!atom) { qCritical() << "Unable to obtain _HILDON_ZOOM_KEY_ATOM"; return; @@ -212,25 +211,44 @@ void AdopterWindow::doGrabVolumeKeys(bool grab) #endif // Q_WS_MAEMO_5 -void AdopterWindow::showEvent(QShowEvent *e) -{ - Trace t("AdopterWindow::showEvent"); - #ifdef Q_OS_SYMBIAN + +void AdopterWindow::updateToolBar() +{ + TRACE; if (toolBar) { - if (portrait()) { + QRect geometry = QApplication::desktop()->geometry(); + bool isPortrait = geometry.width() < geometry.height(); + bool isToolBarHidden = toolBar->isHidden(); + if (isPortrait && isToolBarHidden) { qDebug() << "Show tool bar"; toolBar->setVisible(true); - } else { + } else if (!isPortrait && !isToolBarHidden) { qDebug() << "Hide tool bar"; toolBar->setVisible(false); } } +} + +bool AdopterWindow::portrait() +{ + QRect geometry = QApplication::desktop()->geometry(); + return geometry.width() < geometry.height(); +} + #endif // Q_OS_SYMBIAN + +void AdopterWindow::showEvent(QShowEvent *e) +{ + Trace t("AdopterWindow::showEvent"); + +#ifdef Q_OS_SYMBIAN + updateToolBar(); +#endif QMainWindow::showEvent(e); #if defined(Q_WS_MAEMO_5) doGrabVolumeKeys(grabbingVolumeKeys); -#endif // Q_WS_MAEMO_5 +#endif placeDecorations(); } @@ -238,17 +256,8 @@ void AdopterWindow::resizeEvent(QResizeEvent *event) { Trace t("AdopterWindow::resizeEvent"); #ifdef Q_OS_SYMBIAN - if (toolBar) { - if (portrait()) { - qDebug() << "Show tool bar"; - toolBar->setVisible(true); - } else { - qDebug() << "Hide tool bar"; - toolBar->setVisible(false); - } - } -#endif // Q_OS_SYMBIAN - + updateToolBar(); +#endif QMainWindow::resizeEvent(event); placeDecorations(); } @@ -294,12 +303,6 @@ void AdopterWindow::onSettingsChanged(const QString &key) } } -bool AdopterWindow::portrait() -{ - QRect geometry = QApplication::desktop()->geometry(); - return geometry.width() < geometry.height(); -} - void AdopterWindow::placeDecorations() { Trace t("AdopterWindow::placeDecorations"); @@ -316,7 +319,7 @@ void AdopterWindow::placeDecorations() #ifdef Q_OS_SYMBIAN // Work around Symbian bug: If tool bar is hidden, increase bottom // decorator widgets' Y coordinates by the tool bar's height - if (!portrait() && toolBar) { + if (toolBar && toolBar->isHidden()) { toolBarHeight = toolBar->height(); } diff --git a/adopterwindow.h b/adopterwindow.h index eb30d53..841b527 100644 --- a/adopterwindow.h +++ b/adopterwindow.h @@ -61,9 +61,6 @@ public slots: void onSettingsChanged(const QString &key); protected: - /** Return true, if we are in portrait mode. */ - bool portrait(); - /** Handle key press events. */ void keyPressEvent(QKeyEvent *event); @@ -76,10 +73,18 @@ protected: /** Handle resize events. */ void resizeEvent(QResizeEvent *event); +#ifdef Q_OS_SYMBIAN + /** Update toolbar visibility. */ + void updateToolBar(); + + /** Return true in portrait mode. */ + bool portrait(); +#endif // Q_OS_SYMBIAN + #ifdef Q_WS_MAEMO_5 /** Actually grab the volume keys. */ void doGrabVolumeKeys(bool grab); -#endif +#endif // Q_WS_MAEMO_5 protected slots: void placeDecorations(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 22a06fe..763fb06 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -187,7 +187,7 @@ void MainWindow::showRegular() fullScreenWindow->hide(); show(); -#if 0 // #if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_SYMBIAN) activateWindow(); #endif } @@ -203,7 +203,7 @@ void MainWindow::showBig() fullScreenWindow->showFullScreen(); hide(); -#if 0 // #ifdef Q_OS_SYMBIAN +#ifdef Q_OS_SYMBIAN fullScreenWindow->activateWindow(); #endif } -- 1.7.9.5