mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
updated page information widget visual style
This commit is contained in:
parent
5dea77bb54
commit
c015558223
@ -1,58 +1,45 @@
|
|||||||
#include "page_label_widget.h"
|
#include "page_label_widget.h"
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QtWidgets>
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QPropertyAnimation>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
|
|
||||||
PageLabelWidget::PageLabelWidget(QWidget * parent)
|
PageLabelWidget::PageLabelWidget(QWidget * parent)
|
||||||
:QWidget(parent)
|
:QWidget(parent)
|
||||||
{
|
{
|
||||||
animation = new QPropertyAnimation(this,"pos");
|
animation = new QPropertyAnimation(this,"pos");
|
||||||
animation->setDuration(150);
|
animation->setDuration(150);
|
||||||
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
|
animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
|
||||||
|
|
||||||
int verticalRes = QApplication::desktop()->screenGeometry().height();
|
|
||||||
|
|
||||||
imgLabel = new QLabel(this);
|
|
||||||
QPixmap p;
|
|
||||||
if (verticalRes <= 1024)
|
|
||||||
p.load(":/images/numPagesLabel.png");
|
|
||||||
else if (verticalRes <= 1200)
|
|
||||||
p.load(":/images/numPagesLabelMedium.png");
|
|
||||||
else
|
|
||||||
p.load(":/images/numPagesLabelBig.png");
|
|
||||||
imgLabel->resize(p.size());
|
|
||||||
imgLabel->setPixmap(p);
|
|
||||||
|
|
||||||
textLabel = new QLabel(this);
|
|
||||||
textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
|
|
||||||
if(verticalRes <= 1024)
|
|
||||||
textLabel->setStyleSheet("QLabel { color : white; font-size:12px; padding-left:8px; }");
|
|
||||||
else if (verticalRes <= 1200)
|
|
||||||
textLabel->setStyleSheet("QLabel { color : white; font-size:16px; padding-left:8px;}");
|
|
||||||
else
|
|
||||||
textLabel->setStyleSheet("QLabel { color : white; font-size:20px; padding-left:8px; }");
|
|
||||||
|
|
||||||
//informationLabel->setAutoFillBackground(true);
|
int verticalRes = QApplication::desktop()->screenGeometry().height();
|
||||||
//textLabel->setFont(QFont("courier new bold", 12));
|
|
||||||
//textLabel->resize(100,25);
|
|
||||||
|
|
||||||
resize(p.size());
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
//por defecto aparece oculto
|
layout->setMargin(0);
|
||||||
if(parent != 0)
|
setContentsMargins(0,0,0,0);
|
||||||
move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
|
|
||||||
/*QSize size = textLabel->sizeHint();
|
|
||||||
|
|
||||||
int w = width(); // returns screen width
|
QSize labelSize;
|
||||||
int h = height(); // returns screen height
|
if (verticalRes <= 1024)
|
||||||
int mw = size.width();
|
labelSize = QSize(135, 30);
|
||||||
int mh = size.height();
|
else if (verticalRes <= 1200)
|
||||||
int cw = (w-mw)/2;
|
labelSize = QSize(170, 35);
|
||||||
int ch = 0;
|
else
|
||||||
textLabel->move(cw,ch);*/
|
labelSize = QSize(205, 45);
|
||||||
}
|
|
||||||
|
textLabel = new QLabel(this);
|
||||||
|
textLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);
|
||||||
|
if(verticalRes <= 1024)
|
||||||
|
textLabel->setStyleSheet("QLabel { color : white; font-size:12px; padding-left:8px; }");
|
||||||
|
else if (verticalRes <= 1200)
|
||||||
|
textLabel->setStyleSheet("QLabel { color : white; font-size:16px; padding-left:8px;}");
|
||||||
|
else
|
||||||
|
textLabel->setStyleSheet("QLabel { color : white; font-size:20px; padding-left:8px; }");
|
||||||
|
|
||||||
|
setFixedSize(labelSize);
|
||||||
|
|
||||||
|
if(parent != 0)
|
||||||
|
move(QPoint((parent->geometry().size().width()-this->width()),-this->height()));
|
||||||
|
|
||||||
|
layout->addWidget(textLabel);
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
void PageLabelWidget::show()
|
void PageLabelWidget::show()
|
||||||
{
|
{
|
||||||
@ -76,7 +63,6 @@ void PageLabelWidget::show()
|
|||||||
|
|
||||||
void PageLabelWidget::hide()
|
void PageLabelWidget::hide()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running)
|
if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running)
|
||||||
{
|
{
|
||||||
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
|
QWidget * parent = dynamic_cast<QWidget *>(this->parent());
|
||||||
@ -93,18 +79,15 @@ void PageLabelWidget::hide()
|
|||||||
|
|
||||||
void PageLabelWidget::setText(const QString & text)
|
void PageLabelWidget::setText(const QString & text)
|
||||||
{
|
{
|
||||||
textLabel->setText(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()
|
void PageLabelWidget::updatePosition()
|
||||||
{
|
{
|
||||||
|
@ -10,11 +10,11 @@ class PageLabelWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QLabel * imgLabel;
|
|
||||||
QLabel * textLabel;
|
QLabel * textLabel;
|
||||||
QPropertyAnimation * animation;
|
QPropertyAnimation * animation;
|
||||||
|
|
||||||
//void resizeEvent(QResizeEvent * event);
|
protected:
|
||||||
|
virtual void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PageLabelWidget(QWidget * parent);
|
PageLabelWidget(QWidget * parent);
|
||||||
@ -26,4 +26,4 @@ public slots:
|
|||||||
void updatePosition();
|
void updatePosition();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user