mirror of
https://github.com/YACReader/yacreader
synced 2025-11-08 11:04:41 -05:00
Add slider in goto_flow_toolbar
This commit is contained in:
@ -216,7 +216,8 @@ void GoToFlow::setFlowType(FlowType flowType)
|
|||||||
|
|
||||||
void GoToFlow::updateConfig(QSettings * settings)
|
void GoToFlow::updateConfig(QSettings * settings)
|
||||||
{
|
{
|
||||||
Q_UNUSED(settings)
|
GoToFlowWidget::updateConfig(settings);
|
||||||
|
|
||||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||||
flow->setFlowType(Configuration::getConfiguration().getFlowType());
|
flow->setFlowType(Configuration::getConfiguration().getFlowType());
|
||||||
resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7);
|
resize(5*imageSize.width(), toolBar->height() + imageSize.height()*1.7);
|
||||||
|
|||||||
@ -79,8 +79,9 @@ void GoToFlowGL::setImageReady(int index,const QByteArray & imageData)
|
|||||||
|
|
||||||
void GoToFlowGL::updateConfig(QSettings * settings)
|
void GoToFlowGL::updateConfig(QSettings * settings)
|
||||||
{
|
{
|
||||||
Performance performance = medium;
|
GoToFlowWidget::updateConfig(settings);
|
||||||
|
|
||||||
|
Performance performance = medium;
|
||||||
switch (settings->value(PERFORMANCE).toInt())
|
switch (settings->value(PERFORMANCE).toInt())
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
@ -2,18 +2,42 @@
|
|||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
|
GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
|
||||||
:QWidget(parent)
|
:QStackedWidget(parent)
|
||||||
{
|
{
|
||||||
//elementos interactivos
|
//elementos interactivos
|
||||||
QVBoxLayout * mainLayout = new QVBoxLayout;
|
QWidget * normal = new QWidget(this); // container widget
|
||||||
bar = new QWidget(this);
|
QWidget * quickNavi = new QWidget(this); // container widget
|
||||||
QHBoxLayout * bottom = new QHBoxLayout(bar);
|
addWidget(normal);
|
||||||
bottom->addStretch();
|
addWidget(quickNavi);
|
||||||
bottom->addWidget(new QLabel("<b>" + tr("Page : ") + "</b>",bar));
|
QHBoxLayout * normalLayout = new QHBoxLayout(normal);
|
||||||
bottom->addWidget(edit = new QLineEdit(bar));
|
QHBoxLayout * naviLayout = new QHBoxLayout(quickNavi);
|
||||||
v = new QIntValidator(bar);
|
normal->setLayout(normalLayout);
|
||||||
|
quickNavi->setLayout(naviLayout);
|
||||||
|
|
||||||
|
slider = new QSlider(Qt::Horizontal,this);
|
||||||
|
slider->setStyleSheet(
|
||||||
|
"QSlider::groove:horizontal {"
|
||||||
|
" border: 1px solid white;"
|
||||||
|
" border-radius: 6px;"
|
||||||
|
" background: rgba(255, 255, 255, 50);"
|
||||||
|
" margin: 2px 0;"
|
||||||
|
"}"
|
||||||
|
"QSlider::handle:horizontal {"
|
||||||
|
" background: rgba(0, 0, 0, 200);"
|
||||||
|
" border: 1px solid white;"
|
||||||
|
" width: 24px;"
|
||||||
|
" border-radius: 6px;"
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); });
|
||||||
|
|
||||||
|
pageHint = new QLabel("<b>" + tr("Page : ") + "</b>",this);
|
||||||
|
v = new QIntValidator(this);
|
||||||
v->setBottom(1);
|
v->setBottom(1);
|
||||||
|
edit = new QLineEdit(this);
|
||||||
edit->setValidator(v);
|
edit->setValidator(v);
|
||||||
edit->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
edit->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||||
edit->setStyleSheet("QLineEdit {border: 1px solid #77000000; background: #55000000; color: white; padding: 3px 5px 5px 5px; margin: 13px 5px 12px 5px; font-weight:bold}");
|
edit->setStyleSheet("QLineEdit {border: 1px solid #77000000; background: #55000000; color: white; padding: 3px 5px 5px 5px; margin: 13px 5px 12px 5px; font-weight:bold}");
|
||||||
@ -29,41 +53,51 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
|
|||||||
QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
|
QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
|
||||||
"QPushButton:focus { border: none; outline: none;}"
|
"QPushButton:focus { border: none; outline: none;}"
|
||||||
"QPushButton:pressed {background-image: url(:/images/imgCenterSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
|
"QPushButton:pressed {background-image: url(:/images/imgCenterSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
|
||||||
centerButton = new QPushButton(bar);
|
centerButton = new QPushButton(this);
|
||||||
//centerButton->setIcon(QIcon(":/images/center.png"));
|
//centerButton->setIcon(QIcon(":/images/center.png"));
|
||||||
centerButton->setStyleSheet(centerButtonCSS);
|
centerButton->setStyleSheet(centerButtonCSS);
|
||||||
centerButton->setFixedSize(26,50);
|
centerButton->setFixedSize(26,50);
|
||||||
centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
|
centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
|
||||||
connect(centerButton,SIGNAL(clicked()),this,SLOT(centerSlide()));
|
connect(centerButton,SIGNAL(clicked()),this,SLOT(centerSlide()));
|
||||||
bottom->addWidget(centerButton);
|
|
||||||
|
|
||||||
QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
|
QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} "
|
||||||
"QPushButton:focus { border: none; outline: none;}"
|
"QPushButton:focus { border: none; outline: none;}"
|
||||||
"QPushButton:pressed {background-image: url(:/images/imgGoToSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
|
"QPushButton:pressed {background-image: url(:/images/imgGoToSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} ";
|
||||||
goToButton = new QPushButton(bar);
|
goToButton = new QPushButton(this);
|
||||||
//goToButton->setIcon(QIcon(":/images/goto.png"));
|
//goToButton->setIcon(QIcon(":/images/goto.png"));
|
||||||
goToButton->setStyleSheet(goToButtonCSS);
|
goToButton->setStyleSheet(goToButtonCSS);
|
||||||
goToButton->setFixedSize(32,50);
|
goToButton->setFixedSize(32,50);
|
||||||
goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
|
goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
|
||||||
|
|
||||||
connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo()));
|
connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo()));
|
||||||
bottom->addWidget(goToButton);
|
|
||||||
|
|
||||||
bottom->addStretch();
|
normalLayout->setMargin(0);
|
||||||
bottom->setMargin(0);
|
normalLayout->setSpacing(0);
|
||||||
bottom->setSpacing(0);
|
normalLayout->addStretch();
|
||||||
|
normalLayout->addWidget(pageHint);
|
||||||
bar->setLayout(bottom);
|
normalLayout->addWidget(edit);
|
||||||
|
normalLayout->addWidget(centerButton);
|
||||||
|
normalLayout->addWidget(goToButton);
|
||||||
|
normalLayout->addStretch();
|
||||||
|
|
||||||
mainLayout->setMargin(0);
|
naviLayout->setContentsMargins(5, 0, 0, 0);
|
||||||
mainLayout->setSpacing(0);
|
naviLayout->setSpacing(2);
|
||||||
mainLayout->addWidget(bar);
|
naviLayout->addWidget(slider);
|
||||||
|
naviLayout->addWidget(goToButton);
|
||||||
|
|
||||||
setLayout(mainLayout);
|
switchLayout();
|
||||||
|
|
||||||
setFixedHeight(50);
|
setFixedHeight(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GoToFlowToolBar::switchLayout()
|
||||||
|
{
|
||||||
|
if (Configuration::getConfiguration().getQuickNaviMode())
|
||||||
|
setCurrentIndex(1);
|
||||||
|
else
|
||||||
|
setCurrentIndex(0);
|
||||||
|
}
|
||||||
|
|
||||||
void GoToFlowToolBar::paintEvent(QPaintEvent *)
|
void GoToFlowToolBar::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
@ -78,11 +112,13 @@ void GoToFlowToolBar::paintEvent(QPaintEvent *)
|
|||||||
void GoToFlowToolBar::setPage(int pageNumber)
|
void GoToFlowToolBar::setPage(int pageNumber)
|
||||||
{
|
{
|
||||||
edit->setText(QString::number(pageNumber+1));
|
edit->setText(QString::number(pageNumber+1));
|
||||||
|
slider->setValue(pageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoToFlowToolBar::setTop(int numPages)
|
void GoToFlowToolBar::setTop(int numPages)
|
||||||
{
|
{
|
||||||
v->setTop(numPages);
|
v->setTop(numPages);
|
||||||
|
slider->setMaximum(numPages-1); // min is 0
|
||||||
}
|
}
|
||||||
|
|
||||||
void GoToFlowToolBar::goTo()
|
void GoToFlowToolBar::goTo()
|
||||||
|
|||||||
@ -2,24 +2,30 @@
|
|||||||
#define GOTO_FLOW_TOOLBAR_H
|
#define GOTO_FLOW_TOOLBAR_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QStackedWidget.h>
|
||||||
|
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QIntValidator;
|
class QIntValidator;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QSlider;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
class GoToFlowToolBar : public QWidget
|
class GoToFlowToolBar : public QStackedWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QLineEdit * edit;
|
QLineEdit * edit;
|
||||||
|
QSlider * slider;
|
||||||
QIntValidator * v;
|
QIntValidator * v;
|
||||||
QPushButton * centerButton;
|
QPushButton * centerButton;
|
||||||
QPushButton * goToButton;
|
QPushButton * goToButton;
|
||||||
|
QLabel * pageHint;
|
||||||
QWidget * bar;
|
QWidget * bar;
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GoToFlowToolBar(QWidget * parent = 0);
|
GoToFlowToolBar(QWidget * parent = 0);
|
||||||
|
void switchLayout();
|
||||||
public slots:
|
public slots:
|
||||||
void setPage(int pageNumber);
|
void setPage(int pageNumber);
|
||||||
void setTop(int numPages);
|
void setTop(int numPages);
|
||||||
|
|||||||
@ -51,6 +51,12 @@ void GoToFlowWidget::keyPressEvent(QKeyEvent* event)
|
|||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GoToFlowWidget::updateConfig(QSettings * settings)
|
||||||
|
{
|
||||||
|
Q_UNUSED(settings)
|
||||||
|
toolBar->switchLayout();
|
||||||
|
}
|
||||||
|
|
||||||
void GoToFlowWidget::updateSize()
|
void GoToFlowWidget::updateSize()
|
||||||
{
|
{
|
||||||
// called by parent in resizeEvent
|
// called by parent in resizeEvent
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public slots:
|
|||||||
virtual void setNumSlides(unsigned int slides) = 0;
|
virtual void setNumSlides(unsigned int slides) = 0;
|
||||||
virtual void setImageReady(int index,const QByteArray & image) = 0;
|
virtual void setImageReady(int index,const QByteArray & image) = 0;
|
||||||
virtual void updateSize();
|
virtual void updateSize();
|
||||||
virtual void updateConfig(QSettings * settings) = 0;
|
virtual void updateConfig(QSettings * settings);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent* event);
|
void keyPressEvent(QKeyEvent* event);
|
||||||
|
|||||||
Reference in New Issue
Block a user