mirror of
				https://github.com/YACReader/yacreader
				synced 2025-11-04 01:05:06 -05:00 
			
		
		
		
	updated page information widget visual style
This commit is contained in:
		@ -1,30 +1,27 @@
 | 
			
		||||
#include "page_label_widget.h"
 | 
			
		||||
 | 
			
		||||
#include <QLabel>
 | 
			
		||||
#include <QHBoxLayout>
 | 
			
		||||
#include <QPropertyAnimation>
 | 
			
		||||
#include <QApplication>
 | 
			
		||||
#include <QDesktopWidget>
 | 
			
		||||
#include <QtWidgets>
 | 
			
		||||
 | 
			
		||||
PageLabelWidget::PageLabelWidget(QWidget * parent)
 | 
			
		||||
    :QWidget(parent)
 | 
			
		||||
	{
 | 
			
		||||
{
 | 
			
		||||
    animation = new QPropertyAnimation(this,"pos");
 | 
			
		||||
    animation->setDuration(150);
 | 
			
		||||
    animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
 | 
			
		||||
 | 
			
		||||
    int verticalRes = QApplication::desktop()->screenGeometry().height();
 | 
			
		||||
 | 
			
		||||
	imgLabel = new QLabel(this);
 | 
			
		||||
	QPixmap p;
 | 
			
		||||
    QHBoxLayout *layout = new QHBoxLayout;
 | 
			
		||||
    layout->setMargin(0);
 | 
			
		||||
    setContentsMargins(0,0,0,0);
 | 
			
		||||
 | 
			
		||||
    QSize labelSize;
 | 
			
		||||
    if (verticalRes <= 1024)
 | 
			
		||||
		p.load(":/images/numPagesLabel.png");
 | 
			
		||||
        labelSize = QSize(135, 30);
 | 
			
		||||
    else if (verticalRes <= 1200)
 | 
			
		||||
		p.load(":/images/numPagesLabelMedium.png");
 | 
			
		||||
        labelSize = QSize(170, 35);
 | 
			
		||||
    else
 | 
			
		||||
		p.load(":/images/numPagesLabelBig.png");
 | 
			
		||||
	imgLabel->resize(p.size());
 | 
			
		||||
	imgLabel->setPixmap(p);
 | 
			
		||||
        labelSize = QSize(205, 45);
 | 
			
		||||
 | 
			
		||||
    textLabel = new QLabel(this);
 | 
			
		||||
    textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
 | 
			
		||||
@ -35,24 +32,14 @@ PageLabelWidget::PageLabelWidget(QWidget * parent)
 | 
			
		||||
    else
 | 
			
		||||
        textLabel->setStyleSheet("QLabel { color : white; font-size:20px; padding-left:8px; }");
 | 
			
		||||
 | 
			
		||||
	//informationLabel->setAutoFillBackground(true);
 | 
			
		||||
	//textLabel->setFont(QFont("courier new bold", 12));
 | 
			
		||||
	//textLabel->resize(100,25);
 | 
			
		||||
    setFixedSize(labelSize);
 | 
			
		||||
 | 
			
		||||
	resize(p.size());
 | 
			
		||||
	//por defecto aparece oculto
 | 
			
		||||
    if(parent != 0)
 | 
			
		||||
        move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
 | 
			
		||||
	/*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);*/
 | 
			
		||||
	}
 | 
			
		||||
    layout->addWidget(textLabel);
 | 
			
		||||
    setLayout(layout);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PageLabelWidget::show()
 | 
			
		||||
{
 | 
			
		||||
@ -76,7 +63,6 @@ void PageLabelWidget::show()
 | 
			
		||||
 | 
			
		||||
void PageLabelWidget::hide()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running)
 | 
			
		||||
	{
 | 
			
		||||
		QWidget * parent = dynamic_cast<QWidget *>(this->parent());
 | 
			
		||||
@ -94,17 +80,14 @@ void PageLabelWidget::hide()
 | 
			
		||||
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)
 | 
			
		||||
void PageLabelWidget::paintEvent(QPaintEvent *)
 | 
			
		||||
{
 | 
			
		||||
	move(QPoint((((QWidget *) parent())->geometry().size().width()-this->width())/2,0));
 | 
			
		||||
}*/
 | 
			
		||||
    QPainter painter(this);
 | 
			
		||||
 | 
			
		||||
    painter.fillRect(0,0,width(),height(),QColor("#BB000000"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void PageLabelWidget::updatePosition()
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
@ -10,11 +10,11 @@ class PageLabelWidget : public QWidget
 | 
			
		||||
{
 | 
			
		||||
Q_OBJECT
 | 
			
		||||
private:
 | 
			
		||||
	QLabel * imgLabel;
 | 
			
		||||
	QLabel * textLabel;
 | 
			
		||||
	QPropertyAnimation * animation;
 | 
			
		||||
 | 
			
		||||
	//void resizeEvent(QResizeEvent * event);
 | 
			
		||||
protected:
 | 
			
		||||
    virtual void paintEvent(QPaintEvent *);
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	PageLabelWidget(QWidget * parent);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user