From 166f29f9d4d6e2ed8080e78d38f45edd68315be4 Mon Sep 17 00:00:00 2001 From: Akos Polster Date: Sun, 28 Nov 2010 04:47:16 +0100 Subject: [PATCH] Further improve window resizing. --- adopterwindow.cpp | 39 +++++++++++++++++++-------------------- fullscreenwindow.cpp | 8 ++++---- fullscreenwindow.h | 6 +++--- mainwindow.cpp | 15 +++++++-------- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/adopterwindow.cpp b/adopterwindow.cpp index 3299af1..e51c506 100644 --- a/adopterwindow.cpp +++ b/adopterwindow.cpp @@ -29,7 +29,7 @@ AdopterWindow::AdopterWindow(QWidget *parent): QVBoxLayout *layout = new QVBoxLayout(frame); layout->setMargin(0); frame->setLayout(layout); - frame->show(); + //frame->show(); setCentralWidget(frame); #ifdef Q_OS_SYMBIAN @@ -70,8 +70,8 @@ void AdopterWindow::takeBookView(BookView *view, bookView = view; bookView->setParent(this); - bookView->show(); centralWidget()->layout()->addWidget(bookView); + bookView->show(); progress = prog; previousButton = previous; @@ -85,6 +85,7 @@ void AdopterWindow::leaveBookView() { TRACE; if (bookView) { + bookView->hide(); centralWidget()->layout()->removeWidget(bookView); } bookView = 0; @@ -100,12 +101,12 @@ bool AdopterWindow::hasBookView() void AdopterWindow::show() { + Trace t("AdopterWindow::show"); #ifdef Q_OS_SYMBIAN foreach (QWidget *w, QApplication::allWidgets()) { w->setContextMenuPolicy(Qt::NoContextMenu); } showMaximized(); - raise(); #else QMainWindow::show(); #endif @@ -215,32 +216,18 @@ void AdopterWindow::showEvent(QShowEvent *e) { Trace t("AdopterWindow::showEvent"); + QMainWindow::showEvent(e); #if defined(Q_WS_MAEMO_5) doGrabVolumeKeys(grabbingVolumeKeys); #endif // Q_WS_MAEMO_5 - QMainWindow::showEvent(e); + placeDecorations(); } 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 - - if (hasBookView()) { - QTimer::singleShot(100, this, SLOT(placeDecorations())); - } QMainWindow::resizeEvent(event); + placeDecorations(); } void AdopterWindow::keyPressEvent(QKeyEvent *event) @@ -294,6 +281,18 @@ void AdopterWindow::placeDecorations() { Trace t("AdopterWindow::placeDecorations"); +#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 + if (!hasBookView()) { return; } diff --git a/fullscreenwindow.cpp b/fullscreenwindow.cpp index 047c01a..c9e16c2 100644 --- a/fullscreenwindow.cpp +++ b/fullscreenwindow.cpp @@ -35,18 +35,18 @@ FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent) connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore())); } -void FullScreenWindow::showFullScreen() +void FullScreenWindow::showEvent(QShowEvent *e) { - Trace t("FullScreenWindow::showFullScreen"); - AdopterWindow::showFullScreen(); + Trace t("FullScreenWindow::showEvent"); + AdopterWindow::showEvent(e); placeChildren(); } void FullScreenWindow::resizeEvent(QResizeEvent *e) { Trace t("FullScreenWindow::resizeEvent"); - QTimer::singleShot(100, this, SLOT(placeChildren())); AdopterWindow::resizeEvent(e); + placeChildren(); } void FullScreenWindow::placeChildren() diff --git a/fullscreenwindow.h b/fullscreenwindow.h index bd93a10..d91408c 100644 --- a/fullscreenwindow.h +++ b/fullscreenwindow.h @@ -20,9 +20,6 @@ class FullScreenWindow: public AdopterWindow public: explicit FullScreenWindow(QWidget *parent); - /** Swith to full screen, and flash the restore button. */ - void showFullScreen(); - /** * Adopt children. * Same as @AdopterWindow::takeChildren(), but saves prog, previous @@ -39,6 +36,9 @@ protected: /** Handle size (and orientation) change. */ void resizeEvent(QResizeEvent *e); + /** Handle show event. */ + void showEvent(QShowEvent *e); + protected slots: /** Re-align adopted child windows. */ void placeChildren(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 54c892b..22a06fe 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -131,9 +131,6 @@ MainWindow::MainWindow(QWidget *parent): connect(next, SIGNAL(triggered()), this, SLOT(goToNextPage())); connect(prev, SIGNAL(triggered()), this, SLOT(goToPreviousPage())); - // Adopt view, show window - showRegular(); - #ifdef DORIAN_TEST_MODEL (void)new ModelTest(Library::instance(), this); #endif @@ -168,6 +165,9 @@ void MainWindow::initialize() library->setNowReading(sorted.mapToSource(sorted.index(0, 0))); } } + + // Show in regular (non full-screen) mode + showRegular(); } void MainWindow::onCurrentBookChanged() @@ -186,7 +186,8 @@ void MainWindow::showRegular() fullScreenWindow->hide(); show(); -#if defined(Q_OS_SYMBIAN) + +#if 0 // #if defined(Q_OS_SYMBIAN) activateWindow(); #endif } @@ -199,12 +200,10 @@ void MainWindow::showBig() leaveBookView(); fullScreenWindow->takeBookView(view, prog, prev, next); -// #ifdef Q_OS_SYMBIAN + fullScreenWindow->showFullScreen(); hide(); -// #endif - fullScreenWindow->showFullScreen(); -#ifdef Q_OS_SYMBIAN +#if 0 // #ifdef Q_OS_SYMBIAN fullScreenWindow->activateWindow(); #endif } -- 1.7.9.5