GoTo dialogs: Restrict input values to existing pages

This commit is contained in:
Felix Kauselmann 2021-07-06 10:27:24 +02:00
parent 54b9952253
commit df32cf01fb
3 changed files with 9 additions and 13 deletions

View File

@ -60,12 +60,10 @@ void GoToDialog::setupUI()
void GoToDialog::goTo() void GoToDialog::goTo()
{ {
unsigned int page = pageNumber->text().toInt(); unsigned int page = pageNumber->text().toInt();
pageNumber->clear(); if (page >= 1 && page <= v->top()) {
if (page >= 1)
emit(goToPage(page - 1)); emit(goToPage(page - 1));
close();
close(); }
} }
void GoToDialog::setNumPages(unsigned int numPages) void GoToDialog::setNumPages(unsigned int numPages)

View File

@ -109,8 +109,10 @@ void GoToFlowToolBar::setTop(int numPages)
void GoToFlowToolBar::goTo() void GoToFlowToolBar::goTo()
{ {
if (edit->text().toInt() != 0) unsigned int page = edit->text().toInt();
emit(goTo(edit->text().toInt() - 1)); if (page >= 1 && page <= v->top()) {
emit(goTo(page - 1));
}
} }
void GoToFlowToolBar::centerSlide() void GoToFlowToolBar::centerSlide()

View File

@ -11,7 +11,7 @@
GoToFlowWidget::GoToFlowWidget(QWidget *parent) GoToFlowWidget::GoToFlowWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
mainLayout = new QVBoxLayout; mainLayout = new QVBoxLayout(this);
mainLayout->setMargin(0); mainLayout->setMargin(0);
mainLayout->setSpacing(0); mainLayout->setSpacing(0);
@ -22,11 +22,7 @@ GoToFlowWidget::GoToFlowWidget(QWidget *parent)
//toolBar->installEventFilter(this); //toolBar->installEventFilter(this);
} }
GoToFlowWidget::~GoToFlowWidget() GoToFlowWidget::~GoToFlowWidget() { }
{
delete toolBar;
delete mainLayout;
}
void GoToFlowWidget::setPageNumber(int page) void GoToFlowWidget::setPageNumber(int page)
{ {