Skip to content

Commit 7e0c173

Browse files
committed
page selector added
1 parent 2bbccb9 commit 7e0c173

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

src/tools.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extern void setLineStyle(int style);
6363

6464
extern OverView *ov;
6565

66-
extern QLabel *pageLabel;
66+
extern QPushButton *pageLabel;
6767

6868
extern QWidget *penSettings;
6969
extern QWidget *colorDialog;

src/tools/background.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../tools.h"
22

3-
QLabel* pageLabel;
3+
QPushButton* pageLabel;
44

55
void setupBackground(){
66
penButtons[TRANSPARENT] = create_button(":images/paper-transparent.svg", [=](){
@@ -89,7 +89,16 @@ void setupBackground(){
8989
});
9090
set_shortcut(penButtons[CUSTOM], Qt::Key_O, Qt::AltModifier);
9191

92-
pageLabel = new QLabel("0");
92+
pageLabel = create_button_text("0", [=](){
93+
bool ok;
94+
int number = QInputDialog::getInt(mainWidget, _("Go page"),
95+
_("Page:"), 0, 0, drawing->max, 1, &ok);
96+
if (ok) {
97+
drawing->goPage(number);
98+
backgroundStyleEvent();
99+
updateGoBackButtons();
100+
}
101+
});
93102

94103
toolButtons[OVERLAYSCALEUP] = create_button(":images/zoom-in.svg", [=](){
95104
board->ratios[drawing->getPageNum()] += 10;

src/tools/update.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ void updateGoBackButtons(){
4141
toolButtons[BACK]->setEnabled(drawing->isBackAvailable());
4242
toolButtons[NEXT]->setEnabled(drawing->isNextAvailable());
4343
toolButtons[PREVPAGE]->setEnabled(drawing->getPageNum() > 0);
44+
toolButtons[NEXTPAGE]->setEnabled(drawing->getPageNum() < drawing->max);
4445
pageLabel->setText(QString::number(drawing->getPageNum()));
4546
}
4647

src/utils/pdf.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ void loadPdf(QString path){
2323
doc = Poppler::Document::load(path);
2424
doc->setRenderHint(Poppler::Document::Antialiasing, true);
2525
doc->setRenderHint(Poppler::Document::TextAntialiasing, true);
26+
drawing->max = doc->numPages()-1;
27+
drawing->goPage(0);
28+
backgroundStyleEvent();
29+
updateGoBackButtons();
30+
2631
}
2732

2833
QImage getPdfImage(int num, float ratio){

src/widgets/DrawingWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class DrawingWidget : public QWidget {
112112
QColor penColor;
113113
MovableWidget* cropWidget;
114114
int penSize[10];
115+
int max = 99;
115116
void initializeImage(const QSize &size);
116117
void goPrevious();
117118
void goPage(int i);

0 commit comments

Comments
 (0)