mirror of
https://github.com/YACReader/yacreader
synced 2025-06-03 09:08:20 -04:00
close zoom slider when it loses its focus
This commit is contained in:
parent
84ea312b0e
commit
be0ef4f20f
@ -28,6 +28,8 @@ void YACReaderSliderAction::updateZoomRatio(int value)
|
||||
YACReaderSlider::YACReaderSlider(QWidget *parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
QHBoxLayout* pLayout = new QHBoxLayout();
|
||||
|
||||
pLayout->addStretch();
|
||||
@ -71,12 +73,26 @@ YACReaderSlider::YACReaderSlider(QWidget *parent)
|
||||
slider->setMaximum(500);
|
||||
slider->setPageStep(5);
|
||||
|
||||
slider->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
int value = Configuration::getConfiguration().getZoomLevel()*100;
|
||||
slider->setValue(value);
|
||||
percentageLabel->setText(QString("%1 %").arg(value));
|
||||
connect(slider,SIGNAL(valueChanged(int)),this,SLOT(updateText(int)));
|
||||
}
|
||||
|
||||
void YACReaderSlider::show()
|
||||
{
|
||||
QWidget::show();
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void YACReaderSlider::focusOutEvent(QFocusEvent * event)
|
||||
{
|
||||
QWidget::focusOutEvent(event);
|
||||
hide();
|
||||
}
|
||||
|
||||
void YACReaderSlider::updateText(int value)
|
||||
{
|
||||
percentageLabel->setText(QString("%1 %").arg(value));
|
||||
|
@ -14,8 +14,11 @@ private:
|
||||
QSlider * slider;
|
||||
|
||||
public:
|
||||
|
||||
YACReaderSlider (QWidget * parent = 0);
|
||||
void show();
|
||||
|
||||
protected:
|
||||
virtual void focusOutEvent(QFocusEvent * event);
|
||||
|
||||
public slots:
|
||||
void updateText(int value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user