sortedlibrary.cpp \
bookmarkinfodialog.cpp \
dialog.cpp \
- chaptersdialog.cpp
+ chaptersdialog.cpp \
+ fullscreenwindow.cpp
HEADERS += \
mainwindow.h \
ncxhandler.h \
bookmarkinfodialog.h \
dialog.h \
- chaptersdialog.h
+ chaptersdialog.h \
+ fullscreenwindow.h
RESOURCES += \
dorian.qrc
--- /dev/null
+#include <QtGui>
+
+#include "fullscreenwindow.h"
+#include "translucentbutton.h"
+
+FullScreenWindow::FullScreenWindow(QWidget *child, QWidget *parent):
+ QMainWindow(parent)
+{
+ Q_ASSERT(parent);
+#ifdef Q_WS_MAEMO_5
+ setAttribute(Qt::WA_Maemo5StackedWindow, true);
+ setAttribute(Qt::WA_Maemo5PortraitOrientation,
+ parent->testAttribute(Qt::WA_Maemo5PortraitOrientation));
+ setAttribute(Qt::WA_Maemo5LandscapeOrientation,
+ parent->testAttribute(Qt::WA_Maemo5LandscapeOrientation));
+#endif // Q_WS_MAEMO_5
+ child->setParent(this);
+ setCentralWidget(child);
+ restoreButton = new TranslucentButton("view-fullscreen", this);
+}
+
+void FullScreenWindow::showFullScreen()
+{
+ QWidget::showFullScreen();
+ restoreButton->flash();
+}
+
+void FullScreenWindow::MOUSE_ACTIVATE_EVENT(QMouseEvent *event)
+{
+ if (fullScreenZone().contains(event->x(), event->y())) {
+ emit restore();
+ }
+ QMainWindow::MOUSE_ACTIVATE_EVENT(event);
+}
+
+QRect FullScreenWindow::fullScreenZone() const
+{
+ return QRect(width() / 2 - 45, height() - 104, 95, 95);
+}
+
+void FullScreenWindow::resizeEvent(QResizeEvent *e)
+{
+ restoreButton->setGeometry(fullScreenZone());
+ QMainWindow::resizeEvent(e);
+}
--- /dev/null
+#ifndef FULLSCREENWINDOW_H
+#define FULLSCREENWINDOW_H
+
+#include <QMainWindow>
+
+class TranslucentButton;
+
+class FullScreenWindow: public QMainWindow
+{
+ Q_OBJECT
+public:
+ explicit FullScreenWindow(QWidget *child, QWidget *parent);
+ void showFullScreen();
+
+signals:
+ void restore();
+
+public slots:
+
+protected:
+#ifdef Q_WS_MAEMO_5
+# define MOUSE_ACTIVATE_EVENT mouseReleaseEvent
+#else
+# define MOUSE_ACTIVATE_EVENT mousePressEvent
+#endif
+ virtual void MOUSE_ACTIVATE_EVENT(QMouseEvent *event);
+ virtual void resizeEvent(QResizeEvent *event);
+ QRect fullScreenZone() const;
+ TranslucentButton *restoreButton;
+};
+
+#endif // FULLSCREENWINDOW_H
#include "librarydialog.h"
#include "devtools.h"
#include "mainwindow.h"
-#include "translucentbutton.h"
#include "settingswindow.h"
#include "bookmarksdialog.h"
#include "settings.h"
#include "chaptersdialog.h"
+#include "fullscreenwindow.h"
#ifdef DORIAN_TEST_MODEL
#include "modeltest.h"
const int WIN_BIG_TIMER = 3000;
MainWindow::MainWindow(QWidget *parent):
- QMainWindow(parent), view(0), isFullscreen(false)
+ QMainWindow(parent), view(0), fullScreenWindow(0)
{
#ifdef Q_WS_MAEMO_5
setAttribute(Qt::WA_Maemo5StackedWindow, true);
connect(Library::instance(), SIGNAL(nowReadingChanged()),
this, SLOT(onCurrentBookChanged()));
- normalFlags = windowFlags();
- restoreButton = new TranslucentButton("view-fullscreen", this);
-
// Load book on command line, or load last read book, or load default book
Library *library = Library::instance();
if (QCoreApplication::arguments().size() == 2) {
void MainWindow::showNormal()
{
qDebug() << "MainWindow::showNormal";
- isFullscreen = false;
- setWindowFlags(normalFlags);
- hide();
- setGeometry(normalGeometry);
- toolBar->show();
- restoreButton->hide();
+ view->setParent(this);
+ setCentralWidget(view);
show();
+ delete fullScreenWindow;
+ fullScreenWindow = 0;
}
void MainWindow::showFullScreen()
{
qDebug() << "MainWindow::showFullscreen";
- normalGeometry = geometry();
- isFullscreen = true;
- toolBar->hide();
- setWindowFlags(normalFlags | WIN_BIG_FLAGS);
- showMaximized();
- restoreButton->flash();
+ fullScreenWindow = new FullScreenWindow(view, this);
+ fullScreenWindow->showFullScreen();
+ connect(fullScreenWindow, SIGNAL(restore()), this, SLOT(showNormal()));
}
void MainWindow::setCurrentBook(const QModelIndex ¤t)
}
}
-void MainWindow::MOUSE_ACTIVATE_EVENT(QMouseEvent *event)
-{
- qDebug() << "MainWindow::mousePress/ReleaseEvent at" << event->pos()
- << "against" << fullScreenZone();
- if (isFullscreen && fullScreenZone().contains(event->x(), event->y())) {
- qDebug() << " In fullScreenZone";
- showNormal();
- }
- QMainWindow::MOUSE_ACTIVATE_EVENT(event);
-}
-
-QRect MainWindow::fullScreenZone() const
-{
- return QRect(width() / 2 - 45, height() - 104, 95, 95);
-}
-
-void MainWindow::resizeEvent(QResizeEvent *event)
-{
- (void)event;
- restoreButton->setGeometry(fullScreenZone());
-}
-
void MainWindow::closeEvent(QCloseEvent *event)
{
qDebug() << "MainWindow::closeEvent";
class DevTools;
class BookView;
class Book;
-class TranslucentButton;
+class FullScreenWindow;
class MainWindow: public QMainWindow
{
void onGoToChapter(int index);
protected:
-#ifdef Q_WS_MAEMO5
-# define MOUSE_ACTIVATE_EVENT mouseReleaseEvent
-#else
-# define MOUSE_ACTIVATE_EVENT mousePressEvent
-#endif
- virtual void MOUSE_ACTIVATE_EVENT(QMouseEvent *event);
- virtual void resizeEvent(QResizeEvent *event);
virtual void closeEvent(QCloseEvent *event);
private:
void setCurrentBook(const QModelIndex ¤t);
QAction *addToolBarAction(const QObject *receiver, const char *member,
const QString &name);
- QRect fullScreenZone() const;
BookView *view;
QAction *settingsAction;
QAction *libraryAction;
QDialog *settings;
DevTools *devTools;
QModelIndex mCurrent;
- Qt::WindowFlags normalFlags;
- TranslucentButton *restoreButton;
- bool isFullscreen;
- QRect normalGeometry;
+ FullScreenWindow *fullScreenWindow;
};
#endif // MAINWINDOW_H
+dorian (0.0.12-1) unstable; urgency=low
+
+ * Make full screen truly full screen
+
+ -- Akos Polster <akos@pipacs.com> Tue, 28 Jul 2010 20:00:00 +0200
+
dorian (0.0.11-1) unstable; urgency=low
* Facelift bookmark manager
QWidget(parent), name(name_), mOpacity(1.)
{
setGeometry(0, 0, 50, 50);
- hide();
+ show();
}
-void TranslucentButton::paintEvent(QPaintEvent *e)
+void TranslucentButton::paintEvent(QPaintEvent *)
{
- (void)e;
- QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing, true);
- painter.drawPixmap(0, 0, QPixmap(ICON_PREFIX + name + ".png").
- scaled(QSize(95, 95), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+ if (mOpacity < 1) {
+ QPainter painter(this);
+ painter.setRenderHint(QPainter::Antialiasing, true);
+ painter.drawPixmap(0, 0, QPixmap(ICON_PREFIX + name + ".png").scaled(
+ QSize(95, 95), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
+ }
}
void TranslucentButton::flash()
ani->setStartValue(0.);
ani->setEndValue(1.);
ani->setEasingCurve(QEasingCurve::OutQuart);
- show();
ani->start(QPropertyAnimation::DeleteWhenStopped);
- connect(ani, SIGNAL(destroyed()), this, SLOT(onAnimationEnd()));
}
void TranslucentButton::setOpacity(qreal opacity)
mOpacity = opacity;
update();
}
-
-void TranslucentButton::onAnimationEnd()
-{
- hide();
-}
qreal opacity() const {return mOpacity;}
void setOpacity(qreal opacity);
-signals:
-
-public slots:
- void onAnimationEnd();
-
protected:
virtual void paintEvent(QPaintEvent *);