Q_ASSERT(previous);
Q_ASSERT(next);
- leaveBookView();
+ if (bookView) {
+ return;
+ }
bookView = view;
bookView->setParent(this);
centralWidget()->layout()->addWidget(bookView);
- bookView->show();
+ // bookView->show();
progress = prog;
previousButton = previous;
void AdopterWindow::leaveBookView()
{
TRACE;
- if (bookView) {
- bookView->hide();
- centralWidget()->layout()->removeWidget(bookView);
+
+ if (!bookView) {
+ return;
}
+
+ // bookView->hide();
+ centralWidget()->layout()->removeWidget(bookView);
bookView = 0;
progress = 0;
nextButton = 0;
#endif // Q_WS_MAEMO_5
-void AdopterWindow::showEvent(QShowEvent *e)
+void AdopterWindow::showEvent(QShowEvent *event)
{
Trace t("AdopterWindow::showEvent");
- MainBase::showEvent(e);
+ MainBase::showEvent(event);
#if defined(Q_WS_MAEMO_5)
doGrabVolumeKeys(grabbingVolumeKeys);
#endif
void AdopterWindow::resizeEvent(QResizeEvent *event)
{
Trace t("AdopterWindow::resizeEvent");
+
MainBase::resizeEvent(event);
placeDecorations();
-
#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
// Restore previous reading position
if (bookView) {
Trace t("AdopterWindow::placeDecorations");
if (!hasBookView()) {
+ qDebug() << "Doesn't have the book view";
return;
}
+ qDebug() << "Has the book view";
int extraHeight = 0;
QRect geo = bookView->geometry();
qDebug() << "bookView:" << geo;
-#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 (isToolBarHidden()) {
- // extraHeight = toolBarHeight();
- // }
-
- // Work around another Symbian bug: When returning from full screen mode
- // in landscape, the book view widget's height is miscalculated.
- // My apologies for this kludge
- if (geo.height() == 288) {
- qDebug() << "Adjusting bottom Y";
- extraHeight -= 288 - 223;
- }
-#endif // Q_OS_SYMBIAN
-
progress->setGeometry(geo.x(),
geo.y() + geo.height() - progress->thickness() + extraHeight,
geo.width(), progress->thickness());
{\r
TRACE;\r
\r
-#ifdef Q_WS_MAEMO_5\r
+#if defined(Q_WS_MAEMO_5)\r
setAttribute(Qt::WA_Maemo5StackedWindow, true);\r
#endif\r
\r
QVBoxLayout *layout = new QVBoxLayout(frame);\r
layout->setMargin(0);\r
frame->setLayout(layout);\r
- //frame->show();\r
setCentralWidget(frame);\r
\r
-#ifdef Q_OS_SYMBIAN\r
+#if defined(Q_OS_SYMBIAN)\r
QAction *closeAction = new QAction(parent? tr("Back"): tr("Exit"), this);\r
closeAction->setSoftKeyRole(QAction::NegativeSoftKey);\r
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));\r
QMainWindow::addAction(closeAction);\r
+#endif // Q_OS_SYMBIAN\r
+}\r
+\r
+void MainBase::addToolBar()\r
+{\r
+ TRACE;\r
+\r
+ if (toolBar) {\r
+ return;\r
+ }\r
+\r
+#if defined(Q_OS_SYMBIAN)\r
+ toolBar = new QToolBar("", this);\r
+ QMainWindow::addToolBar(Qt::BottomToolBarArea, toolBar);\r
#else\r
- // Tool bar\r
+ toolBar = QMainWindow::addToolBar("");\r
+#endif\r
+\r
setUnifiedTitleAndToolBarOnMac(true);\r
- toolBar = addToolBar("");\r
toolBar->setMovable(false);\r
toolBar->setFloatable(false);\r
toolBar->toggleViewAction()->setVisible(false);\r
+\r
#if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5)\r
toolBar->setIconSize(QSize(42, 42));\r
#endif\r
-#endif // Q_OS_SYMBIAN\r
}\r
\r
QAction *MainBase::addToolBarAction(QObject *receiver,\r
QAction *action;\r
#ifdef Q_OS_SYMBIAN\r
if (important) {\r
- if (!toolBar) {\r
- // Create tool bar if needed\r
- toolBar = new QToolBar("", this);\r
- addToolBar(Qt::BottomToolBarArea, toolBar);\r
- }\r
// Add tool bar action\r
+ addToolBar();\r
QPushButton *button = new QPushButton(this);\r
button->setIconSize(QSize(60, 60));\r
button->setFixedHeight(60);\r
connect(action, SIGNAL(triggered()), receiver, member);\r
#else\r
Q_UNUSED(important);\r
+ addToolBar();\r
action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),\r
text, receiver, member);\r
#endif\r
\r
void MainBase::addToolBarSpace()\r
{\r
+ addToolBar();\r
QFrame *frame = new QFrame(toolBar);\r
frame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);\r
toolBar->addWidget(frame);\r
}\r
\r
-void MainBase::updateToolBar()\r
-{\r
-#if 0 // ifdef Q_OS_SYMBIAN\r
- TRACE;\r
- if (toolBar) {\r
- QRect geometry = QApplication::desktop()->geometry();\r
- bool isPortrait = geometry.width() < geometry.height();\r
- bool isToolBarHidden = toolBar->isHidden();\r
- if (isPortrait && isToolBarHidden) {\r
- qDebug() << "Show tool bar";\r
- toolBar->setVisible(true);\r
- } else if (!isPortrait && !isToolBarHidden) {\r
- qDebug() << "Hide tool bar";\r
- toolBar->setVisible(false);\r
- }\r
- }\r
-#endif // Q_OS_SYMBIAN\r
-}\r
-\r
-void MainBase::showEvent(QShowEvent *event)\r
-{\r
- Trace t("MainBase::showEvent");\r
- updateToolBar();\r
- QMainWindow::showEvent(event);\r
-}\r
-\r
-void MainBase::resizeEvent(QResizeEvent *event)\r
-{\r
- Trace t("MainBase::resizeEvent");\r
- updateToolBar();\r
- QMainWindow::resizeEvent(event);\r
-}\r
-\r
-void MainBase::hideToolBar()\r
-{\r
- if (toolBar) {\r
- toolBar->hide();\r
- }\r
-}\r
-\r
-bool MainBase::isToolBarHidden()\r
-{\r
- return toolBar && toolBar->isHidden();\r
-}\r
-\r
int MainBase::toolBarHeight()\r
{\r
return toolBar? toolBar->height(): 0;\r
const QString &iconName, const QString &text,\r
bool important = false);\r
\r
+ /** Add tool bar. */\r
+ void addToolBar();\r
+\r
/** Add spacing to tool bar. */\r
void addToolBarSpace();\r
\r
void show();\r
\r
protected:\r
- /** Handle resize event: Manage tool bar visibility. */\r
- void resizeEvent(QResizeEvent *event);\r
-\r
- /** Handle show event: Manage tool bar visibility. */\r
- void showEvent(QShowEvent *event);\r
-\r
- /**\r
- * Update toolb ar visibility.\r
- * On Symbian, the tool bar is not visible in landscape mode.\r
- */\r
- void updateToolBar();\r
-\r
- /** Hide tool bar if visible. */\r
- void hideToolBar();\r
-\r
- /** Return true if the tool bar is present and hidden. */\r
- bool isToolBarHidden();\r
-\r
/** Return the height of the tool bar (or 0 if there is no tool bar). */\r
int toolBarHeight();\r
\r