mirror of
https://github.com/YACReader/yacreader
synced 2025-07-19 05:24:57 -04:00
a?adido widget para la gesti?n de la informationLabel
This commit is contained in:
@ -45,6 +45,7 @@ HEADERS += comic.h \
|
|||||||
translator.h \
|
translator.h \
|
||||||
goto_flow_gl.h \
|
goto_flow_gl.h \
|
||||||
goto_flow_widget.h \
|
goto_flow_widget.h \
|
||||||
|
page_label_widget.h \
|
||||||
../common/pictureflow.h \
|
../common/pictureflow.h \
|
||||||
../common/custom_widgets.h \
|
../common/custom_widgets.h \
|
||||||
../common/check_new_version.h \
|
../common/check_new_version.h \
|
||||||
@ -69,6 +70,7 @@ SOURCES += comic.cpp \
|
|||||||
translator.cpp \
|
translator.cpp \
|
||||||
goto_flow_gl.cpp \
|
goto_flow_gl.cpp \
|
||||||
goto_flow_widget.cpp \
|
goto_flow_widget.cpp \
|
||||||
|
page_label_widget.cpp \
|
||||||
../common/pictureflow.cpp \
|
../common/pictureflow.cpp \
|
||||||
../common/custom_widgets.cpp \
|
../common/custom_widgets.cpp \
|
||||||
../common/check_new_version.cpp \
|
../common/check_new_version.cpp \
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
<file>../images/dictionary.png</file>
|
<file>../images/dictionary.png</file>
|
||||||
<file>../images/alwaysOnTop.png</file>
|
<file>../images/alwaysOnTop.png</file>
|
||||||
<file>../images/adjustToFullSize.png</file>
|
<file>../images/adjustToFullSize.png</file>
|
||||||
|
<file>../images/numPagesLabel.png</file>
|
||||||
<file>../images/helpImages/open.png</file>
|
<file>../images/helpImages/open.png</file>
|
||||||
<file>../images/helpImages/openFolder.png</file>
|
<file>../images/helpImages/openFolder.png</file>
|
||||||
<file>../images/helpImages/next.png</file>
|
<file>../images/helpImages/next.png</file>
|
||||||
|
94
YACReader/page_label_widget.cpp
Normal file
94
YACReader/page_label_widget.cpp
Normal 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()));
|
||||||
|
}
|
29
YACReader/page_label_widget.h
Normal file
29
YACReader/page_label_widget.h
Normal 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
|
@ -9,6 +9,7 @@
|
|||||||
#include "goto_dialog.h"
|
#include "goto_dialog.h"
|
||||||
#include "translator.h"
|
#include "translator.h"
|
||||||
#include "onstart_flow_selection_dialog.h"
|
#include "onstart_flow_selection_dialog.h"
|
||||||
|
#include "page_label_widget.h"
|
||||||
|
|
||||||
#include <QWebView>
|
#include <QWebView>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
@ -56,12 +57,8 @@ drag(false)
|
|||||||
content->setMouseTracking(true);
|
content->setMouseTracking(true);
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
informationLabel = new QLabel(this);
|
informationLabel = new PageLabelWidget(this);
|
||||||
informationLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
|
|
||||||
informationLabel->setAutoFillBackground(true);
|
|
||||||
informationLabel->setFont(QFont("courier new", 12));
|
|
||||||
informationLabel->hide();
|
informationLabel->hide();
|
||||||
informationLabel->resize(100,25);
|
|
||||||
|
|
||||||
showCursor();
|
showCursor();
|
||||||
|
|
||||||
@ -160,6 +157,8 @@ void Viewer::open(QString pathFile)
|
|||||||
//render->update();
|
//render->update();
|
||||||
|
|
||||||
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
|
verticalScrollBar()->setSliderPosition(verticalScrollBar()->minimum());
|
||||||
|
|
||||||
|
informationLabel->setText("...");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::showMessageErrorOpening()
|
void Viewer::showMessageErrorOpening()
|
||||||
@ -171,12 +170,14 @@ void Viewer::next()
|
|||||||
{
|
{
|
||||||
direction = 1;
|
direction = 1;
|
||||||
render->nextPage();
|
render->nextPage();
|
||||||
|
updateInformation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::prev()
|
void Viewer::prev()
|
||||||
{
|
{
|
||||||
direction = -1;
|
direction = -1;
|
||||||
render->previousPage();
|
render->previousPage();
|
||||||
|
updateInformation();
|
||||||
}
|
}
|
||||||
void Viewer::showGoToDialog()
|
void Viewer::showGoToDialog()
|
||||||
{
|
{
|
||||||
@ -407,7 +408,7 @@ void Viewer::resizeEvent(QResizeEvent * event)
|
|||||||
{
|
{
|
||||||
updateContentSize();
|
updateContentSize();
|
||||||
goToFlow->move(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
|
goToFlow->move(QPoint((width()-goToFlow->width())/2,height()-goToFlow->height()));
|
||||||
informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
|
informationLabel->updatePosition();
|
||||||
QScrollArea::resizeEvent(event);
|
QScrollArea::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +488,7 @@ void Viewer::hideMagnifyingGlass()
|
|||||||
void Viewer::informationSwitch()
|
void Viewer::informationSwitch()
|
||||||
{
|
{
|
||||||
information?informationLabel->hide():informationLabel->show();
|
information?informationLabel->hide():informationLabel->show();
|
||||||
informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
|
//informationLabel->move(QPoint((width()-informationLabel->width())/2,0));
|
||||||
information=!information;
|
information=!information;
|
||||||
//TODO it shouldn't be neccesary
|
//TODO it shouldn't be neccesary
|
||||||
informationLabel->adjustSize();
|
informationLabel->adjustSize();
|
||||||
|
@ -26,6 +26,7 @@ class GoToDialog;
|
|||||||
class YACReaderTranslator;
|
class YACReaderTranslator;
|
||||||
class GoToFlowWidget;
|
class GoToFlowWidget;
|
||||||
class Bookmarks;
|
class Bookmarks;
|
||||||
|
class PageLabelWidget;
|
||||||
|
|
||||||
class Viewer : public QScrollArea
|
class Viewer : public QScrollArea
|
||||||
{
|
{
|
||||||
@ -80,7 +81,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
|||||||
private:
|
private:
|
||||||
bool information;
|
bool information;
|
||||||
bool doublePage;
|
bool doublePage;
|
||||||
QLabel * informationLabel;
|
PageLabelWidget * informationLabel;
|
||||||
//QTimer * scroller;
|
//QTimer * scroller;
|
||||||
QPropertyAnimation * verticalScroller;
|
QPropertyAnimation * verticalScroller;
|
||||||
int posByStep;
|
int posByStep;
|
||||||
|
BIN
images/numPagesLabel.png
Normal file
BIN
images/numPagesLabel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 585 B |
Reference in New Issue
Block a user