mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04: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)
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
GoToFlowWidget::updateConfig(settings);
|
||||
|
||||
imageSize = Configuration::getConfiguration().getGotoSlideSize();
|
||||
flow->setFlowType(Configuration::getConfiguration().getFlowType());
|
||||
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)
|
||||
{
|
||||
Performance performance = medium;
|
||||
GoToFlowWidget::updateConfig(settings);
|
||||
|
||||
Performance performance = medium;
|
||||
switch (settings->value(PERFORMANCE).toInt())
|
||||
{
|
||||
case 0:
|
||||
|
@ -2,18 +2,42 @@
|
||||
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
GoToFlowToolBar::GoToFlowToolBar(QWidget * parent)
|
||||
:QWidget(parent)
|
||||
:QStackedWidget(parent)
|
||||
{
|
||||
//elementos interactivos
|
||||
QVBoxLayout * mainLayout = new QVBoxLayout;
|
||||
bar = new QWidget(this);
|
||||
QHBoxLayout * bottom = new QHBoxLayout(bar);
|
||||
bottom->addStretch();
|
||||
bottom->addWidget(new QLabel("<b>" + tr("Page : ") + "</b>",bar));
|
||||
bottom->addWidget(edit = new QLineEdit(bar));
|
||||
v = new QIntValidator(bar);
|
||||
QWidget * normal = new QWidget(this); // container widget
|
||||
QWidget * quickNavi = new QWidget(this); // container widget
|
||||
addWidget(normal);
|
||||
addWidget(quickNavi);
|
||||
QHBoxLayout * normalLayout = new QHBoxLayout(normal);
|
||||
QHBoxLayout * naviLayout = new QHBoxLayout(quickNavi);
|
||||
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);
|
||||
edit = new QLineEdit(this);
|
||||
edit->setValidator(v);
|
||||
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}");
|
||||
@ -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;} "
|
||||
"QPushButton:focus { border: none; outline: 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->setStyleSheet(centerButtonCSS);
|
||||
centerButton->setFixedSize(26,50);
|
||||
centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
|
||||
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;} "
|
||||
"QPushButton:focus { border: none; outline: 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->setStyleSheet(goToButtonCSS);
|
||||
goToButton->setFixedSize(32,50);
|
||||
goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect,true);
|
||||
|
||||
connect(goToButton,SIGNAL(clicked()),this,SLOT(goTo()));
|
||||
bottom->addWidget(goToButton);
|
||||
|
||||
bottom->addStretch();
|
||||
bottom->setMargin(0);
|
||||
bottom->setSpacing(0);
|
||||
|
||||
bar->setLayout(bottom);
|
||||
normalLayout->setMargin(0);
|
||||
normalLayout->setSpacing(0);
|
||||
normalLayout->addStretch();
|
||||
normalLayout->addWidget(pageHint);
|
||||
normalLayout->addWidget(edit);
|
||||
normalLayout->addWidget(centerButton);
|
||||
normalLayout->addWidget(goToButton);
|
||||
normalLayout->addStretch();
|
||||
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
mainLayout->addWidget(bar);
|
||||
naviLayout->setContentsMargins(5, 0, 0, 0);
|
||||
naviLayout->setSpacing(2);
|
||||
naviLayout->addWidget(slider);
|
||||
naviLayout->addWidget(goToButton);
|
||||
|
||||
setLayout(mainLayout);
|
||||
switchLayout();
|
||||
|
||||
setFixedHeight(50);
|
||||
}
|
||||
|
||||
void GoToFlowToolBar::switchLayout()
|
||||
{
|
||||
if (Configuration::getConfiguration().getQuickNaviMode())
|
||||
setCurrentIndex(1);
|
||||
else
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void GoToFlowToolBar::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
@ -78,11 +112,13 @@ void GoToFlowToolBar::paintEvent(QPaintEvent *)
|
||||
void GoToFlowToolBar::setPage(int pageNumber)
|
||||
{
|
||||
edit->setText(QString::number(pageNumber+1));
|
||||
slider->setValue(pageNumber);
|
||||
}
|
||||
|
||||
void GoToFlowToolBar::setTop(int numPages)
|
||||
{
|
||||
v->setTop(numPages);
|
||||
slider->setMaximum(numPages-1); // min is 0
|
||||
}
|
||||
|
||||
void GoToFlowToolBar::goTo()
|
||||
|
@ -2,24 +2,30 @@
|
||||
#define GOTO_FLOW_TOOLBAR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget.h>
|
||||
|
||||
class QLineEdit;
|
||||
class QIntValidator;
|
||||
class QPushButton;
|
||||
class QSlider;
|
||||
class QLabel;
|
||||
|
||||
class GoToFlowToolBar : public QWidget
|
||||
class GoToFlowToolBar : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QLineEdit * edit;
|
||||
QSlider * slider;
|
||||
QIntValidator * v;
|
||||
QPushButton * centerButton;
|
||||
QPushButton * goToButton;
|
||||
QLabel * pageHint;
|
||||
QWidget * bar;
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
public:
|
||||
GoToFlowToolBar(QWidget * parent = 0);
|
||||
void switchLayout();
|
||||
public slots:
|
||||
void setPage(int pageNumber);
|
||||
void setTop(int numPages);
|
||||
|
@ -51,6 +51,12 @@ void GoToFlowWidget::keyPressEvent(QKeyEvent* event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void GoToFlowWidget::updateConfig(QSettings * settings)
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
toolBar->switchLayout();
|
||||
}
|
||||
|
||||
void GoToFlowWidget::updateSize()
|
||||
{
|
||||
// called by parent in resizeEvent
|
||||
|
@ -28,7 +28,7 @@ public slots:
|
||||
virtual void setNumSlides(unsigned int slides) = 0;
|
||||
virtual void setImageReady(int index,const QByteArray & image) = 0;
|
||||
virtual void updateSize();
|
||||
virtual void updateConfig(QSettings * settings) = 0;
|
||||
virtual void updateConfig(QSettings * settings);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
Reference in New Issue
Block a user