From c9d5f238437cf804504be6e17f42331dfd02f9be Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Wed, 12 Jan 2011 00:55:23 +0100 Subject: [PATCH] No progress at all. --- mainwindow.cpp | 11 +++++++++-- platform.cpp | 38 ++++++++++++++++++++++++++++++++++++++ platform.h | 7 ++++++- widgets/mainbase.cpp | 23 +++++++++++++++++++++-- widgets/mainbase.h | 5 +++++ 5 files changed, 79 insertions(+), 5 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 583928e..c8f5dfe 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -185,8 +185,12 @@ void MainWindow::showRegular() // Re-parent children fullScreenWindow->leaveBookView(); takeBookView(view, prog, prev, next); - fullScreenWindow->hide(); + +#ifdef Q_OS_SYMBIAN + view->setFixedSize(Platform::availableSize().width(), + Platform::availableSize().height() - Platform::softKeyHeight()); +#endif show(); } @@ -197,8 +201,11 @@ void MainWindow::showBig() // Re-parent children leaveBookView(); fullScreenWindow->takeBookView(view, prog, prev, next); - hide(); + +#ifdef Q_OS_SYMBIAN + view->setFixedSize(Platform::size()); +#endif fullScreenWindow->showFullScreen(); } diff --git a/platform.cpp b/platform.cpp index ac25039..873d4fb 100644 --- a/platform.cpp +++ b/platform.cpp @@ -187,3 +187,41 @@ void Platform::setOrientation(QWidget *widget, const QString &orientation) #endif } } + +int Platform::softKeyHeight() +{ +#if defined(Q_OS_SYMBIAN) + return 62; +#else + return 0; +#endif +} + +int Platform::toolBarIconHeight() +{ +#if defined(Q_OS_SYMBIAN) + return 60; +#elif defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5) + return 40; +#else + return 0; +#endif +} + +QSize Platform::size() +{ + return QApplication::desktop()->geometry().size(); +} + +QSize Platform::availableSize() +{ + QSize s = QApplication::desktop()->availableGeometry().size(); +#if defined(Q_OS_SYMBIAN) + // Work around a Qt bug on Symbian which sometimes forgets to reduce the + // available height by the soft key area height + if (s.height() == 548) { + s.setHeight(s.height() - softKeyHeight()); + } +#endif + return s; +} diff --git a/platform.h b/platform.h index f920f80..30628dd 100644 --- a/platform.h +++ b/platform.h @@ -2,6 +2,7 @@ #define PLATFORM_H #include +#include class QWidget; @@ -18,12 +19,16 @@ public: QString version(); QString downloadDir(); QString defaultFont(); - int defaultZoom(); + static int defaultZoom(); QString defaultOrientation(); void setOrientation(QWidget *widget, const QString &orientation); void information(const QString &label, QWidget *parent = 0); void showBusy(QWidget *w, bool isBusy); QString traceFileName(); + static int softKeyHeight(); + static int toolBarIconHeight(); + static QSize size(); + static QSize availableSize(); }; #endif // PLATFORM_H diff --git a/widgets/mainbase.cpp b/widgets/mainbase.cpp index f2707c8..e560b5d 100755 --- a/widgets/mainbase.cpp +++ b/widgets/mainbase.cpp @@ -36,7 +36,8 @@ void MainBase::addToolBar() #if defined(Q_OS_SYMBIAN) toolBar = new QToolBar("", this); - QMainWindow::addToolBar(Qt::BottomToolBarArea, toolBar); + toolBar->setFixedHeight(Platform::softKeyHeight()); + QMainWindow::addToolBar(Qt::NoToolBarArea, toolBar); #else toolBar = QMainWindow::addToolBar(""); #endif @@ -47,7 +48,8 @@ void MainBase::addToolBar() toolBar->toggleViewAction()->setVisible(false); #if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5) - toolBar->setIconSize(QSize(42, 42)); + toolBar->setIconSize(QSize(Platform::toolBarIconHeight(), + Platform::toolBarIconHeight())); #endif } @@ -112,3 +114,20 @@ void MainBase::show() QMainWindow::show(); #endif } + +#ifdef Q_OS_SYMBIAN + +void MainBase::resizeEvent(QResizeEvent *e) +{ + Trace t("MainBase::resizeEvent"); + + QMainWindow::resizeEvent(e); + if (!toolBar) { + return; + } + QSize available = Platform::availableSize(); + toolBar->setGeometry(0, available.height() - Platform::softKeyHeight(), + available.width(), Platform::softKeyHeight()); +} + +#endif // Q_OS_SYMBIAN diff --git a/widgets/mainbase.h b/widgets/mainbase.h index bf2e83b..c1103a4 100755 --- a/widgets/mainbase.h +++ b/widgets/mainbase.h @@ -42,6 +42,11 @@ protected: /** Return the height of the tool bar (or 0 if there is no tool bar). */ int toolBarHeight(); +#ifdef Q_OS_SYMBIAN + /** Handle resize. */ + void resizeEvent(QResizeEvent *e); +#endif + private: QToolBar *toolBar; /**< Tool bar. */ }; -- 1.7.9.5