From 5dbbaad73b0332006c6434ff8976dd79c13cf0c4 Mon Sep 17 00:00:00 2001 From: Felix Kauselmann Date: Tue, 22 Jun 2021 08:25:54 +0200 Subject: [PATCH] GoTo flows: Untangle and refactor goTo signal to new syntax --- YACReader/goto_flow.cpp | 2 +- YACReader/goto_flow.h | 3 --- YACReader/goto_flow_gl.cpp | 2 +- YACReader/goto_flow_gl.h | 3 --- YACReader/goto_flow_toolbar.cpp | 8 ++++---- YACReader/goto_flow_toolbar.h | 2 +- YACReader/goto_flow_widget.h | 2 ++ YACReader/viewer.cpp | 2 +- 8 files changed, 10 insertions(+), 14 deletions(-) diff --git a/YACReader/goto_flow.cpp b/YACReader/goto_flow.cpp index c1c32b64..a596ac6f 100644 --- a/YACReader/goto_flow.cpp +++ b/YACReader/goto_flow.cpp @@ -43,7 +43,7 @@ GoToFlow::GoToFlow(QWidget *parent, FlowType flowType) connect(flow, &PictureFlow::centerIndexChanged, this, &GoToFlow::preload); connect(flow, &PictureFlow::centerIndexChangedSilent, this, &GoToFlow::preload); - connect(toolBar, SIGNAL(goTo(unsigned int)), this, SIGNAL(goToPage(unsigned int))); + connect(toolBar, &GoToFlowToolBar::goToPage, this, &GoToFlow::goToPage); connect(toolBar, &GoToFlowToolBar::setCenter, flow, &PictureFlow::showSlide); mainLayout->addWidget(flow); diff --git a/YACReader/goto_flow.h b/YACReader/goto_flow.h index 09fe2ce0..efc9f52e 100644 --- a/YACReader/goto_flow.h +++ b/YACReader/goto_flow.h @@ -63,9 +63,6 @@ public slots: void setFlowType(FlowType flowType) override; void updateConfig(QSettings *settings) override; void setFlowRightToLeft(bool b) override; - -signals: - void goToPage(unsigned int page); }; //----------------------------------------------------------------------------- diff --git a/YACReader/goto_flow_gl.cpp b/YACReader/goto_flow_gl.cpp index c4256f8a..323e368d 100644 --- a/YACReader/goto_flow_gl.cpp +++ b/YACReader/goto_flow_gl.cpp @@ -24,7 +24,7 @@ GoToFlowGL::GoToFlowGL(QWidget *parent, FlowType flowType) connect(flow, &YACReaderFlowGL::centerIndexChanged, this, &GoToFlowWidget::setPageNumber); connect(flow, &YACReaderFlowGL::selected, this, &GoToFlowGL::goToPage); - connect(toolBar, SIGNAL(goTo(unsigned int)), this, SIGNAL(goToPage(unsigned int))); + connect(toolBar, &GoToFlowToolBar::goToPage, this, &GoToFlowGL::goToPage); connect(toolBar, &GoToFlowToolBar::setCenter, flow, &YACReaderFlowGL::setCenterIndex); mainLayout->addWidget(flow); diff --git a/YACReader/goto_flow_gl.h b/YACReader/goto_flow_gl.h index 0e827164..683fcd00 100644 --- a/YACReader/goto_flow_gl.h +++ b/YACReader/goto_flow_gl.h @@ -27,9 +27,6 @@ public: void updateConfig(QSettings *settings); void setFlowRightToLeft(bool b) override; -signals: - void goToPage(unsigned int page); - private: YACReaderPageFlowGL *flow; void keyPressEvent(QKeyEvent *event) override; diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index 6a2067dd..0d13f773 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -32,7 +32,7 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) " border-radius: 1px;" "}"); - connect(slider, &QSlider::valueChanged, this, [&](int v) { emit(setCenter(v)); }); + connect(slider, &QSlider::valueChanged, this, [this](int v) { emit(setCenter(v)); }); pageHint = new QLabel("" + tr("Page : ") + "", this); v = new QIntValidator(this); @@ -47,7 +47,7 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) //edit->resize(QSize(54,50)); edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); //edit->setAutoFillBackground(false); - connect(edit, SIGNAL(returnPressed()), this, SLOT(goTo())); + connect(edit, &QLineEdit::returnPressed, this, &GoToFlowToolBar::goTo); QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} " "QPushButton:focus { border: none; outline: none;}" @@ -68,7 +68,7 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) goToButton->setFixedSize(32, 50); goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); - connect(goToButton, SIGNAL(clicked()), this, SLOT(goTo())); + connect(goToButton, &QPushButton::clicked, this, &GoToFlowToolBar::goTo); normalLayout->setMargin(0); normalLayout->setSpacing(0); @@ -110,7 +110,7 @@ void GoToFlowToolBar::setTop(int numPages) void GoToFlowToolBar::goTo() { if (edit->text().toInt() != 0) - emit(goTo(edit->text().toInt() - 1)); + emit(goToPage(edit->text().toInt() - 1)); } void GoToFlowToolBar::centerSlide() diff --git a/YACReader/goto_flow_toolbar.h b/YACReader/goto_flow_toolbar.h index 0fae6884..9368d1cb 100644 --- a/YACReader/goto_flow_toolbar.h +++ b/YACReader/goto_flow_toolbar.h @@ -34,7 +34,7 @@ public slots: void updateOptions(); signals: void setCenter(unsigned int); - void goTo(unsigned int); + void goToPage(unsigned int); }; #endif diff --git a/YACReader/goto_flow_widget.h b/YACReader/goto_flow_widget.h index 95a76578..2104513d 100644 --- a/YACReader/goto_flow_widget.h +++ b/YACReader/goto_flow_widget.h @@ -31,6 +31,8 @@ public slots: virtual void updateSize(); virtual void updateConfig(QSettings *settings); virtual void setFlowRightToLeft(bool b) = 0; +signals: + void goToPage(unsigned int); protected: void keyPressEvent(QKeyEvent *event) override; diff --git a/YACReader/viewer.cpp b/YACReader/viewer.cpp index 92c7071f..bc8587a8 100644 --- a/YACReader/viewer.cpp +++ b/YACReader/viewer.cpp @@ -158,7 +158,7 @@ void Viewer::createConnections() connect(goToDialog, &GoToDialog::goToPage, this, &Viewer::goTo); //goToFlow goTo - connect(goToFlow, SIGNAL(goToPage(unsigned int)), this, SLOT(goTo(unsigned int))); + connect(goToFlow, &GoToFlowWidget::goToPage, this, &Viewer::goTo); //current time auto t = new QTimer(this);