mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
ficheros de c?digo fuente "width_slider" a?adidos al repositorio (se habian olvidado)
This commit is contained in:
parent
be591fde62
commit
850d62e11e
71
YACReader/width_slider.cpp
Normal file
71
YACReader/width_slider.cpp
Normal file
@ -0,0 +1,71 @@
|
||||
#include "width_slider.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include "configuration.h"
|
||||
|
||||
YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
|
||||
:QWidgetAction (0) {
|
||||
|
||||
QWidget* pWidget = new QWidget (NULL);
|
||||
QHBoxLayout* pLayout = new QHBoxLayout();
|
||||
|
||||
pLayout->addStretch();
|
||||
|
||||
percentageLabel = new QLabel ("100%");
|
||||
percentageLabel->setStyleSheet("QLabel { color : white; }");
|
||||
percentageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||
pLayout->addWidget (percentageLabel);
|
||||
slider = new QSlider(NULL);
|
||||
slider->setOrientation(Qt::Horizontal);
|
||||
pLayout->addWidget (slider);
|
||||
|
||||
QString sliderCSS =
|
||||
|
||||
"QSlider::sub-page:horizontal {background-image: url(:/images/sliderSubPage.png); border: 0px; margin-left: 18px;}"
|
||||
"QSlider::add-page:horizontal {background-image: url(:/images/sliderAddPage.png); border: 0px; margin-right: 25px;}"
|
||||
"QSlider::handle:horizontal {image: url(:/images/sliderHandle.png); width: 31px;height:45px; }"
|
||||
"QSlider::groove:horizontal {border-image:url(:/images/sliderGround.png); border-left:-2px; border-right:0;}"
|
||||
;
|
||||
slider->setStyleSheet(sliderCSS);
|
||||
slider->setFixedSize(218,45);
|
||||
|
||||
QLabel* imgLabel = new QLabel(pWidget);
|
||||
QPixmap p(":/images/sliderBackground.png");
|
||||
imgLabel->resize(p.size());
|
||||
imgLabel->setPixmap(p);
|
||||
|
||||
pLayout->setMargin(0);
|
||||
pLayout->setSpacing(0);
|
||||
|
||||
pLayout->setStretchFactor(percentageLabel,1);
|
||||
pLayout->setStretchFactor(slider,0);
|
||||
|
||||
|
||||
pWidget->setLayout (pLayout);
|
||||
pWidget->setAutoFillBackground(false);
|
||||
|
||||
pWidget->setMinimumSize(276,45);
|
||||
|
||||
setDefaultWidget(pWidget);
|
||||
|
||||
slider->setMinimum(50);
|
||||
slider->setMaximum(100);
|
||||
slider->setPageStep(5);
|
||||
|
||||
int value = Configuration::getConfiguration().getFitToWidthRatio()*100;
|
||||
slider->setValue(value);
|
||||
percentageLabel->setText(QString("%1 %").arg(value));
|
||||
connect(slider,SIGNAL(valueChanged(int)),this,SLOT(updateText(int)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void YACReaderSliderAction::updateText(int value)
|
||||
{
|
||||
percentageLabel->setText(QString("%1 %").arg(value));
|
||||
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
|
||||
emit(fitToWidthRatioChanged(value / 100.0f));
|
||||
}
|
27
YACReader/width_slider.h
Normal file
27
YACReader/width_slider.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef WIDTH_SLIDER_H
|
||||
#define WIDTH_SLIDER_H
|
||||
|
||||
#include <QWidgetAction>
|
||||
|
||||
class QLabel;
|
||||
class QSlider;
|
||||
|
||||
class YACReaderSliderAction : public QWidgetAction
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QLabel * percentageLabel;
|
||||
QSlider * slider;
|
||||
public:
|
||||
|
||||
YACReaderSliderAction (QWidget * parent = 0);
|
||||
|
||||
public slots:
|
||||
void updateText(int value);
|
||||
|
||||
|
||||
signals:
|
||||
void fitToWidthRatioChanged(float value);
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user