Add download statistics.
[dorian] / adopterwindow.cpp
index 6a33cf8..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) {
@@ -100,16 +103,27 @@ 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
+    Q_UNUSED(important);
     action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
                                 text, receiver, member);
 #else
-    Q_UNUSED(iconName);
+    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);
@@ -119,6 +133,7 @@ QAction *AdopterWindow::addToolBarAction(QObject *receiver,
     action->setText("");
     action->setToolTip("");
 #endif
+
     return action;
 }