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()
{
unsigned int page = pageNumber->text().toInt();
pageNumber->clear();
if (page >= 1)
if (page >= 1 && page <= v->top()) {
emit(goToPage(page - 1));
close();
close();
}
}
void GoToDialog::setNumPages(unsigned int numPages)

View File

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

View File

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