#include "platform.h"
#include "settings.h"
-AdopterWindow::AdopterWindow(QWidget *parent): QMainWindow(parent), bookView(0)
+AdopterWindow::AdopterWindow(QWidget *parent):
+ 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
#else
// Tool bar
setUnifiedTitleAndToolBarOnMac(true);
- toolBar = addToolBar("controls");
+ toolBar = addToolBar("");
toolBar->setMovable(false);
toolBar->setFloatable(false);
toolBar->toggleViewAction()->setVisible(false);
#endif // Q_OS_SYMBIAN
// Monitor settings
- Settings *settings = Settings::instance();
- connect(settings, SIGNAL(valueChanged(const QString &)),
+ connect(Settings::instance(), SIGNAL(valueChanged(const QString &)),
this, SLOT(onSettingsChanged(const QString &)));
- settings->setValue("usevolumekeys", settings->value("usevolumekeys"));
}
void AdopterWindow::takeChildren(BookView *view, const QList<QWidget *> &others)
if (view) {
bookView = view;
bookView->setParent(centralWidget());
- centralWidget()->layout()->addWidget(bookView);
bookView->show();
+ QVBoxLayout *layout =
+ qobject_cast<QVBoxLayout *>(centralWidget()->layout());
+ layout->addWidget(bookView, 1);
}
foreach (QWidget *child, others) {
if (child) {
}
}
+bool AdopterWindow::hasChild(QWidget *child)
+{
+ if (child == bookView) {
+ return true;
+ }
+ return this == child->parent();
+}
+
void AdopterWindow::show()
{
#ifdef Q_OS_SYMBIAN
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()
void AdopterWindow::onSettingsChanged(const QString &key)
{
- TRACE;
if (key == "usevolumekeys") {
- qDebug() << key;
- grabVolumeKeys(Settings::instance()->value(key).toBool());
+ bool grab = Settings::instance()->value(key, false).toBool();
+ qDebug() << "AdopterWindow::onSettingsChanged: usevolumekeys" << grab;
+ grabVolumeKeys(grab);
}
}