From 5648f4dcb3f32f229b54f94fb4b243ffb2080959 Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Tue, 23 Nov 2010 00:35:02 +0100 Subject: [PATCH] Fix popup widgets' positions. Add tool bar on Symbian. --- adopterwindow.cpp | 2 +- fullscreenwindow.cpp | 43 ++++++++++++++++++------------- fullscreenwindow.h | 4 +++ mainwindow.cpp | 68 +++++++++++++++++++++++++++++++++++++------------- mainwindow.h | 3 +++ pkg/changelog | 1 + 6 files changed, 86 insertions(+), 35 deletions(-) diff --git a/adopterwindow.cpp b/adopterwindow.cpp index a819594..d5bc82b 100644 --- a/adopterwindow.cpp +++ b/adopterwindow.cpp @@ -57,7 +57,7 @@ void AdopterWindow::takeChildren(BookView *view, const QList &others) leaveChildren(); if (view) { bookView = view; - bookView->setParent(centralWidget()); + bookView->setParent(this); bookView->show(); QVBoxLayout *layout = qobject_cast(centralWidget()->layout()); diff --git a/fullscreenwindow.cpp b/fullscreenwindow.cpp index ca8baba..07bf291 100644 --- a/fullscreenwindow.cpp +++ b/fullscreenwindow.cpp @@ -38,14 +38,35 @@ FullScreenWindow::FullScreenWindow(QWidget *parent): void FullScreenWindow::showFullScreen() { - TRACE; + Trace t("FullScreenWindow::showFullScreen"); AdopterWindow::showFullScreen(); - restoreButton->flash(3000); + placeChildren(); } void FullScreenWindow::resizeEvent(QResizeEvent *e) { + Trace t("FullScreenWindow::resizeEvent"); + QTimer::singleShot(100, this, SLOT(placeChildren())); + AdopterWindow::resizeEvent(e); +} + +void FullScreenWindow::takeChildren(BookView *view, + Progress *prog, + TranslucentButton *previous, + TranslucentButton *next) +{ TRACE; + progress = prog; + previousButton = previous; + nextButton = next; + QList otherChildren; + otherChildren << progress << previousButton << nextButton; + AdopterWindow::takeChildren(view, otherChildren); +} + +void FullScreenWindow::placeChildren() +{ + Trace t("FullScreenWindow::placeChildren"); QRect screen = QApplication::desktop()->screenGeometry(); int w = screen.width(); @@ -72,6 +93,9 @@ void FullScreenWindow::resizeEvent(QResizeEvent *e) if (hasChild(progress)) { progress->setGeometry(0, h - progress->thickness(), w, progress->thickness()); + qDebug() << "Screen (FullScreenWindow::resizeEvent)" << w << "x" << h; + qDebug() << "Progress (FullScreenWindow::resizeEvent)" + << progress->geometry(); } if (hasChild(previousButton)) { previousButton->setGeometry( @@ -89,19 +113,4 @@ void FullScreenWindow::resizeEvent(QResizeEvent *e) } restoreButton->flash(3000); - AdopterWindow::resizeEvent(e); -} - -void FullScreenWindow::takeChildren(BookView *view, - Progress *prog, - TranslucentButton *previous, - TranslucentButton *next) -{ - TRACE; - progress = prog; - previousButton = previous; - nextButton = next; - QList otherChildren; - otherChildren << progress << previousButton << nextButton; - AdopterWindow::takeChildren(view, otherChildren); } diff --git a/fullscreenwindow.h b/fullscreenwindow.h index c30c309..df2496c 100644 --- a/fullscreenwindow.h +++ b/fullscreenwindow.h @@ -39,6 +39,10 @@ protected: /** Handle size (and orientation) change. */ void resizeEvent(QResizeEvent *e); +protected slots: + /** Re-align adopted child windows. */ + void placeChildren(); + private: TranslucentButton *restoreButton; Progress *progress; diff --git a/mainwindow.cpp b/mainwindow.cpp index 8f6e2ef..6486ec5 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -64,7 +64,7 @@ MainWindow::MainWindow(QWidget *parent): setCentralWidget(central); // Book view - view = new BookView(central); + view = new BookView(this); view->show(); layout->addWidget(view); @@ -200,10 +200,13 @@ void MainWindow::showRegular() otherChildren << progress << previousButton << nextButton; takeChildren(view, otherChildren); +#if 0 + // Adjust geometry of decorations QRect geo = geometry(); - qDebug() << geo; + qDebug() << "MainWindow (MainWindow::showRegular)" << geo; + qDebug() << "BookView (MainWindow::showRegular)" << view->geometry(); int y = geo.height() - progress->thickness(); #if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN) bool hasToolBar = false; @@ -236,14 +239,13 @@ void MainWindow::showRegular() #endif // Q_WS_MAEMO_5 qDebug() << "previousButton geometry" << previousButton->geometry(); +#endif + fullScreenWindow->hide(); show(); #if defined(Q_OS_SYMBIAN) activateWindow(); #endif - progress->flash(); - nextButton->flash(); - previousButton->flash(); } void MainWindow::showBig() @@ -254,6 +256,8 @@ void MainWindow::showBig() leaveChildren(); fullScreenWindow->takeChildren(view, progress, previousButton, nextButton); +#if 0 + // Adjust geometry of decorations QRect screen = QApplication::desktop()->screenGeometry(); int y = screen.height() - progress->thickness(); @@ -268,16 +272,16 @@ void MainWindow::showBig() previousButton->setGeometry(0, screen.height() - TranslucentButton::pixels, TranslucentButton::pixels, TranslucentButton::pixels); -#ifdef Q_OS_SYMBIAN - hide(); #endif + +// #ifdef Q_OS_SYMBIAN + hide(); +// #endif + fullScreenWindow->showFullScreen(); #ifdef Q_OS_SYMBIAN fullScreenWindow->activateWindow(); #endif - progress->flash(); - nextButton->flash(); - previousButton->flash(); } void MainWindow::setCurrentBook(const QModelIndex ¤t) @@ -442,22 +446,47 @@ void MainWindow::timerEvent(QTimerEvent *event) void MainWindow::resizeEvent(QResizeEvent *e) { - TRACE; + Trace t("MainWindow::resizeEvent"); +#ifdef Q_OS_SYMBIAN + // Tool bar is only useful in portrait mode + bool isPortrait = + (QApplication::desktop()->width() < QApplication::desktop()->height()); + toolBar->setVisible(isPortrait); +#endif + QTimer::singleShot(100, this, SLOT(placeChildren())); + AdopterWindow::resizeEvent(e); +} + +void MainWindow::placeChildren() +{ + Trace t("MainWindow::placeChildren"); int toolBarHeight = 0; #ifdef Q_OS_SYMBIAN // Tool bar is only useful in portrait mode - bool isPortrait = (e->size().width() < e->size().height()); - toolBar->setVisible(isPortrait); + bool isPortrait = + (QApplication::desktop()->width() < QApplication::desktop()->height()); + // toolBar->setVisible(isPortrait); + + // Work around Symbian bug: If there is no tool bar, increase decorator + // widgets' Y coordinates if (!isPortrait) { toolBarHeight = toolBar->height(); } #endif // Q_OS_SYMBIAN - if (bookView) { - qDebug() << "BookView geometry" << bookView->geometry(); - QRect geo = bookView->geometry(); + if (hasChild(view)) { + QRect geo = centralWidget()->geometry(); + qDebug() << "centralWidget (MainWindow::resizeEvent)" << geo; +#ifdef Q_OS_SYMBIAN + // FIXME: When returning from full screen in landscape mode, + // the central widget's height is miscalculated on Symbian. + // My apologies for this kludge + if (geo.height() == 288) { + geo.setHeight(223); + } +#endif // Q_OS_SYMBIAN progress->setGeometry(geo.x(), geo.y() + geo.height() - progress->thickness() + toolBarHeight, geo.width(), progress->thickness()); @@ -467,8 +496,13 @@ void MainWindow::resizeEvent(QResizeEvent *e) nextButton->setGeometry( geo.x() + geo.width() - TranslucentButton::pixels, geo.y(), TranslucentButton::pixels, TranslucentButton::pixels); + progress->flash(); + previousButton->flash(); + nextButton->flash(); + qDebug() << "Progress (MainWindow::resizeEvent)" + << progress->geometry(); } - QMainWindow::resizeEvent(e); + } void MainWindow::about() diff --git a/mainwindow.h b/mainwindow.h index 5de2120..4f499d2 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -55,6 +55,9 @@ protected: void timerEvent(QTimerEvent *event); void resizeEvent(QResizeEvent *event); +protected slots: + void placeChildren(); + private: void setCurrentBook(const QModelIndex ¤t); BookView *view; diff --git a/pkg/changelog b/pkg/changelog index d4bb2f4..800013b 100644 --- a/pkg/changelog +++ b/pkg/changelog @@ -1,6 +1,7 @@ dorian (0.4.0-1) unstable; urgency=low * Fix popup button positions + * Add tool bar on Symbian -- Akos Polster Sun, 21 Nov 2010 02:00:00 +0100 -- 1.7.9.5