#include "settings.h"
AdopterWindow::AdopterWindow(QWidget *parent):
- QMainWindow(parent), bookView(0), grabbingVolumeKeys(false)
+ QMainWindow(parent), bookView(0), grabbingVolumeKeys(false), toolBar(0)
{
TRACE;
QVBoxLayout *layout = new QVBoxLayout(frame);
layout->setMargin(0);
frame->setLayout(layout);
+ frame->show();
setCentralWidget(frame);
#ifdef Q_OS_SYMBIAN
closeAction->setSoftKeyRole(QAction::NegativeSoftKey);
connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
QMainWindow::addAction(closeAction);
-
- // toolBar = new QToolBar(this);
- // toolBar->setFixedWidth(QApplication::desktop()->
- // availableGeometry().width());
- // toolBar->setFixedHeight(70);
- // toolBar->setIconSize(QSize(90, 70));
- // toolBar->setFloatable(false);
- // toolBar->setMovable(false);
- // addToolBar(Qt::BottomToolBarArea, toolBar);
#else
// Tool bar
setUnifiedTitleAndToolBarOnMac(true);
bookView = view;
bookView->setParent(centralWidget());
bookView->show();
- centralWidget()->layout()->addWidget(bookView);
+ QVBoxLayout *layout =
+ qobject_cast<QVBoxLayout *>(centralWidget()->layout());
+ layout->addWidget(bookView, 1);
}
foreach (QWidget *child, others) {
if (child) {
action = toolBar->addAction(QIcon(Platform::instance()->icon(iconName)),
text, receiver, member);
#else
- if (0) { // if (important) {
- qDebug() << "Add Symbian tool bar action";
- QAction *toolBarAction = toolBar->addAction(
- QIcon(Platform::instance()->icon(iconName)),
- text, receiver, member);
- toolBarAction->setText("");
- toolBarAction->setToolTip("");
- connect(toolBarAction, SIGNAL(triggered()), receiver, member);
+ 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);
#include "fullscreenwindow.h"
#include "translucentbutton.h"
+#include "progress.h"
#include "trace.h"
#include "settings.h"
#include "platform.h"
-FullScreenWindow::FullScreenWindow(QWidget *parent): AdopterWindow(parent)
+static const int MARGIN = 9;
+
+FullScreenWindow::FullScreenWindow(QWidget *parent):
+ AdopterWindow(parent), progress(0), previousButton(0), nextButton(0)
{
TRACE;
Q_ASSERT(parent);
setCentralWidget(frame);
restoreButton = new TranslucentButton("view-normal", this);
QRect screen = QApplication::desktop()->screenGeometry();
- restoreButton->setGeometry(screen.width() - TranslucentButton::pixels - 9,
- screen.height() - TranslucentButton::pixels - 9,
- TranslucentButton::pixels, TranslucentButton::pixels);
+ restoreButton->setGeometry(
+ screen.width() - TranslucentButton::pixels - MARGIN,
+ screen.height() - TranslucentButton::pixels - MARGIN,
+ TranslucentButton::pixels,
+ TranslucentButton::pixels);
connect(restoreButton, SIGNAL(triggered()), this, SIGNAL(restore()));
}
}
#endif // Q_WS_MAEMO_5
- restoreButton->setGeometry(w - TranslucentButton::pixels - 9,
- h - TranslucentButton::pixels - 9, TranslucentButton::pixels,
+ restoreButton->setGeometry(
+ w - TranslucentButton::pixels - MARGIN,
+ h - TranslucentButton::pixels - MARGIN,
+ TranslucentButton::pixels,
+ TranslucentButton::pixels);
+
+ if (hasChild(progress)) {
+ progress->setGeometry(0, h - progress->thickness(),
+ w, progress->thickness());
+ }
+ if (hasChild(previousButton)) {
+ previousButton->setGeometry(
+ MARGIN,
+ h - TranslucentButton::pixels - MARGIN,
+ TranslucentButton::pixels,
+ TranslucentButton::pixels);
+ }
+ if (hasChild(nextButton)) {
+ nextButton->setGeometry(
+ w - TranslucentButton::pixels - MARGIN,
+ MARGIN,
+ TranslucentButton::pixels,
TranslucentButton::pixels);
+ }
+
restoreButton->flash(3000);
AdopterWindow::resizeEvent(e);
}
+
+void FullScreenWindow::takeChildren(BookView *view,
+ Progress *prog,
+ TranslucentButton *previous,
+ TranslucentButton *next)
+{
+ TRACE;
+ progress = prog;
+ previousButton = previous;
+ nextButton = next;
+ QList<QWidget *> otherChildren;
+ otherChildren << progress << previousButton << nextButton;
+ AdopterWindow::takeChildren(view, otherChildren);
+}
class QMouseEvent;
class QResizeEvent;
class TranslucentButton;
+class Progress;
/** A full screen window with a restore button. */
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
+ * and next, before calling base class method.
+ */
+ void takeChildren(BookView *bookView, Progress *prog,
+ TranslucentButton *previous, TranslucentButton *next);
+
signals:
/** Emitted when the restore button is pressed. */
void restore();
protected:
+ /** Handle size (and orientation) change. */
void resizeEvent(QResizeEvent *e);
private:
TranslucentButton *restoreButton;
+ Progress *progress;
+ TranslucentButton *previousButton;
+ TranslucentButton *nextButton;
};
#endif // FULLSCREENWINDOW_H
#endif
setWindowTitle("Dorian");
+#ifdef Q_OS_SYMBIAN
+ // Tool bar
+ toolBar = new QToolBar("", this /*frame*/);
+ toolBar->setFixedWidth(QApplication::desktop()->
+ availableGeometry().width());
+ toolBar->setFixedHeight(65);
+ toolBar->setStyleSheet("margin:0;border:0;padding:0");
+ toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
+ addToolBar(Qt::BottomToolBarArea, toolBar);
+#endif
+
// Central widget. Must be an intermediate, because the book view widget
// can be re-parented later
QFrame *central = new QFrame(this);
QRect geo = geometry();
qDebug() << geo;
int y = geo.height() - progress->thickness();
-#if defined(Q_WS_MAEMO_5)
- y -= toolBar->height();
+#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
+ bool hasToolBar = false;
+# if defined(Q_OS_SYMBIAN)
+ hasToolBar =
+ (QApplication::desktop()->width() < QApplication::desktop()->height());
+ qDebug() << (hasToolBar? "Portrait": "Landscape");
+# endif
+ if (!hasToolBar) {
+ y -= toolBar->height();
+ }
#endif
progress->setGeometry(0, y, geo.width(), y + progress->thickness());
-#if defined(Q_WS_MAEMO_5)
- previousButton->setGeometry(0,
- geo.height() - toolBar->height() - TranslucentButton::pixels,
- TranslucentButton::pixels, TranslucentButton::pixels);
+#if defined(Q_WS_MAEMO_5) || defined(Q_OS_SYMBIAN)
+ y = geo.height() - TranslucentButton::pixels;
+ if (!hasToolBar) {
+ y -= toolBar->height();
+ }
+ previousButton->setGeometry(0, y, TranslucentButton::pixels,
+ TranslucentButton::pixels);
nextButton->setGeometry(geo.width() - TranslucentButton::pixels, 0,
TranslucentButton::pixels, TranslucentButton::pixels);
-#elif defined(Q_OS_SYMBIAN)
- previousButton->setGeometry(0, geo.height() - TranslucentButton::pixels,
- TranslucentButton::pixels, TranslucentButton::pixels);
- nextButton->setGeometry(geo.width() - TranslucentButton::pixels,
- 0, TranslucentButton::pixels, TranslucentButton::pixels);
#else
previousButton->setGeometry(0, geo.height() - TranslucentButton::pixels,
TranslucentButton::pixels, TranslucentButton::pixels);
// Re-parent children
leaveChildren();
- QList<QWidget *> otherChildren;
- otherChildren << progress << nextButton << previousButton;
- fullScreenWindow->takeChildren(view, otherChildren);
+ fullScreenWindow->takeChildren(view, progress, previousButton, nextButton);
// Adjust geometry of decorations
QRect screen = QApplication::desktop()->screenGeometry();
{
TRACE;
+ int toolBarHeight = 0;
+
+#ifdef Q_OS_SYMBIAN
+ // Tool bar is only useful in portrait mode
+ bool isPortrait = (e->size().width() < e->size().height());
+ toolBar->setVisible(isPortrait);
+ if (!isPortrait) {
+ toolBarHeight = toolBar->height();
+ }
+#endif // Q_OS_SYMBIAN
+
if (bookView) {
qDebug() << "BookView geometry" << bookView->geometry();
QRect geo = bookView->geometry();
progress->setGeometry(geo.x(),
- geo.y() + geo.height() - progress->thickness(), geo.width(),
- progress->thickness());
+ geo.y() + geo.height() - progress->thickness() + toolBarHeight,
+ geo.width(), progress->thickness());
previousButton->setGeometry(geo.x(),
- geo.y() + geo.height() - TranslucentButton::pixels,
+ geo.y() + geo.height() - TranslucentButton::pixels + toolBarHeight,
TranslucentButton::pixels, TranslucentButton::pixels);
nextButton->setGeometry(
geo.x() + geo.width() - TranslucentButton::pixels,
dorian (0.4.0-1) unstable; urgency=low
+ * Fix popup button positions
+
-- Akos Polster <akos@pipacs.com> Sun, 21 Nov 2010 02:00:00 +0100
dorian (0.3.9-1) unstable; urgency=low