a?adido widget para la gesti?n de la informationLabel

This commit is contained in:
Luis Ángel San Martín
2013-01-21 17:11:26 +01:00
parent 6063bb5dd4
commit e99d690d2d
7 changed files with 137 additions and 9 deletions

View File

@ -45,6 +45,7 @@ HEADERS += comic.h \
translator.h \
goto_flow_gl.h \
goto_flow_widget.h \
page_label_widget.h \
../common/pictureflow.h \
../common/custom_widgets.h \
../common/check_new_version.h \
@ -69,6 +70,7 @@ SOURCES += comic.cpp \
translator.cpp \
goto_flow_gl.cpp \
goto_flow_widget.cpp \
page_label_widget.cpp \
../common/pictureflow.cpp \
../common/custom_widgets.cpp \
../common/check_new_version.cpp \

View File

@ -35,6 +35,7 @@
<file>../images/dictionary.png</file>
<file>../images/alwaysOnTop.png</file>
<file>../images/adjustToFullSize.png</file>
<file>../images/numPagesLabel.png</file>
<file>../images/helpImages/open.png</file>
<file>../images/helpImages/openFolder.png</file>
<file>../images/helpImages/next.png</file>

View File

@ -0,0 +1,94 @@
#include "page_label_widget.h"
#include <QLabel>
#include <QHBoxLayout>
#include <QPropertyAnimation>
PageLabelWidget::PageLabelWidget(QWidget * parent)
:QWidget(parent)
{
animation = new QPropertyAnimation(this,"pos");
animation->setDuration(150);
imgLabel = new QLabel(this);
QPixmap p(":/images/numPagesLabel.png");
imgLabel->resize(p.size());
imgLabel->setPixmap(QPixmap(":/images/numPagesLabel.png"));
textLabel = new QLabel(this);
textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
textLabel->setStyleSheet("QLabel { color : white; }");
//informationLabel->setAutoFillBackground(true);
//textLabel->setFont(QFont("courier new bold", 12));
//textLabel->resize(100,25);
textLabel->setGeometry(imgLabel->geometry());
/*QSize size = textLabel->sizeHint();
int w = width(); // returns screen width
int h = height(); // returns screen height
int mw = size.width();
int mh = size.height();
int cw = (w-mw)/2;
int ch = 0;
textLabel->move(cw,ch);*/
}
void PageLabelWidget::show()
{
if(this->pos().y() <= 0 && animation->state()!=QPropertyAnimation::Running)
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
return;
}
QWidget::show();
//connect(animation,SIGNAL(finished()),this,SLOT(QWidget::hide()));
animation->disconnect();
animation->setStartValue(QPoint((parent->geometry().size().width()-this->width())/2,-this->height()));
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width())/2,0));
animation->start();
}
}
void PageLabelWidget::hide()
{
if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running)
{
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
if(parent == 0)
{
return;
}
//connect(animation,SIGNAL(finished()),this,SLOT(setHidden()));
animation->setStartValue(QPoint((parent->geometry().size().width()-this->width())/2,0));
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width())/2,-this->height()));
animation->start();
}
}
void PageLabelWidget::setText(const QString & text)
{
textLabel->setText(text);
QRect geom = imgLabel->geometry();
QSize size = geom.size();
size.setHeight(size.height() - 10); //TODO remove this amazing magic number
geom.setSize(size);
textLabel->setGeometry(geom);
}
/*void PageLabelWidget::resizeEvent(QResizeEvent * event)
{
move(QPoint((((QWidget *) parent())->geometry().size().width()-this->width())/2,0));
}*/
void PageLabelWidget::updatePosition()
{
move(QPoint((((QWidget *) parent())->geometry().size().width()-this->width())/2,this->pos().y()));
}

View File

@ -0,0 +1,29 @@
#ifndef PAGE_LABEL_WIDGET_H
#define PAGE_LABEL_WIDGET_H
#include <QWidget>
class QLabel;
class QPropertyAnimation;
class PageLabelWidget : public QWidget
{
Q_OBJECT
private:
QLabel * imgLabel;
QLabel * textLabel;
QPropertyAnimation * animation;
//void resizeEvent(QResizeEvent * event);
public:
PageLabelWidget(QWidget * parent);
public slots:
void show();
void hide();
void setText(const QString & text);
void updatePosition();
};
#endif

View File

@ -9,6 +9,7 @@
#include "goto_dialog.h"
#include "translator.h"
#include "onstart_flow_selection_dialog.h"
#include "page_label_widget.h"
#include <QWebView>
#include <QFile>
@ -56,12 +57,8 @@ drag(false)
content->setMouseTracking(true);
setMouseTracking(true);
informationLabel = new QLabel(this);
informationLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
informationLabel->setAutoFillBackground(true);
informationLabel->setFont(QFont("courier new", 12));
informationLabel = new PageLabelWidget(this);
informationLabel->hide();
informationLabel->resize(100,25);
showCursor();
@ -160,6 +157,8 @@ void Viewer::open(QString pathFile)
//render->update();
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
informationLabel->setText("...");
}
void Viewer::showMessageErrorOpening()
@ -171,12 +170,14 @@ void Viewer::next()
{
direction = 1;
render->nextPage();
updateInformation();
}
void Viewer::prev()
{
direction = -1;
render->previousPage();
updateInformation();
}
void Viewer::showGoToDialog()
{
@ -407,7 +408,7 @@ void Viewer::resizeEvent(QResizeEvent * event)
{
updateContentSize();
goToFlow->move(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
informationLabel->updatePosition();
QScrollArea::resizeEvent(event);
}
@ -487,7 +488,7 @@ void Viewer::hideMagnifyingGlass()
void Viewer::informationSwitch()
{
information?informationLabel->hide():informationLabel->show();
informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
//informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
information=!information;
//TODO it shouldn't be neccesary
informationLabel->adjustSize();

View File

@ -26,6 +26,7 @@ class GoToDialog;
class YACReaderTranslator;
class GoToFlowWidget;
class Bookmarks;
class PageLabelWidget;
class Viewer : public QScrollArea
{
@ -80,7 +81,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
private:
bool information;
bool doublePage;
QLabel * informationLabel;
PageLabelWidget * informationLabel;
//QTimer * scroller;
QPropertyAnimation * verticalScroller;
int posByStep;

BIN
images/numPagesLabel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B