Add download statistics.
[dorian] / adopterwindow.cpp
index 3775155..d5bc82b 100644 (file)
 #include "settings.h"
 
 AdopterWindow::AdopterWindow(QWidget *parent):
-    QMainWindow(parent), bookView(0), grabbingVolumeKeys(false)
+    QMainWindow(parent), bookView(0), grabbingVolumeKeys(false), toolBar(0)
 {
     TRACE;
 
 #ifdef Q_WS_MAEMO_5
     setAttribute(Qt::WA_Maemo5StackedWindow, true);
-#endif // Q_WS_MAEMO_5
+#endif
 
     QFrame *frame = new QFrame(this);
     QVBoxLayout *layout = new QVBoxLayout(frame);
     layout->setMargin(0);
     frame->setLayout(layout);
+    frame->show();
     setCentralWidget(frame);
 
 #ifdef Q_OS_SYMBIAN
@@ -36,7 +37,7 @@ AdopterWindow::AdopterWindow(QWidget *parent):
 #else
     // Tool bar
     setUnifiedTitleAndToolBarOnMac(true);
-    toolBar = addToolBar("controls");
+    toolBar = addToolBar("");
     toolBar->setMovable(false);
     toolBar->setFloatable(false);
     toolBar->toggleViewAction()->setVisible(false);
@@ -56,9 +57,11 @@ void AdopterWindow::takeChildren(BookView *view, const QList<QWidget *> &others)
     leaveChildren();
     if (view) {
         bookView = view;
-        bookView->setParent(centralWidget());
-        centralWidget()->layout()->addWidget(bookView);
+        bookView->setParent(this);
         bookView->show();
+        QVBoxLayout *layout =
+                qobject_cast<QVBoxLayout *>(centralWidget()->layout());
+        layout->addWidget(bookView, 1);
     }
     foreach (QWidget *child, others) {
         if (child) {
@@ -76,6 +79,14 @@ void AdopterWindow::leaveChildren()
     }
 }
 
+bool AdopterWindow::hasChild(QWidget *child)
+{
+    if (child == bookView) {
+        return true;
+    }
+    return this == child->parent();
+}
+
 void AdopterWindow::show()
 {
 #ifdef Q_OS_SYMBIAN
@@ -92,20 +103,38 @@ void AdopterWindow::show()
 QAction *AdopterWindow::addToolBarAction(QObject *receiver,
                                          const char *member,
                                          const QString &iconName,
-                                         const QString &text)
+                                         const QString &text,
+                                         bool important)
 {
     TRACE;
     qDebug() << "icon" << iconName << "text" << text;
+    QAction *action;
 #ifndef Q_OS_SYMBIAN
-    return toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
-                              text, receiver, member);
+    Q_UNUSED(important);
+    action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
+                                text, receiver, member);
 #else
-    Q_UNUSED(iconName);
-    QAction *action = new QAction(text, this);
+    if (toolBar && important) {
+        QPushButton *button = new QPushButton(this);
+        button->setIconSize(QSize(60, 60));
+        button->setFixedSize(89, 60);
+        button->setIcon(QIcon(Platform::instance()->icon(iconName)));
+        button->setSizePolicy(QSizePolicy::MinimumExpanding,
+                              QSizePolicy::Maximum);
+        connect(button, SIGNAL(clicked()), receiver, member);
+        toolBar->addWidget(button);
+    }
+    action = new QAction(text, this);
     menuBar()->addAction(action);
     connect(action, SIGNAL(triggered()), receiver, member);
-    return action;
 #endif
+
+#if defined Q_WS_MAEMO_5
+    action->setText("");
+    action->setToolTip("");
+#endif
+
+    return action;
 }
 
 void AdopterWindow::addToolBarSpace()