@@ -29,6 +29,14 @@ bool Viewer::setThumbnail(const Thumbnail &thumbnail, const qint64 taskCount)
2929 return true ;
3030}
3131
32+ void Viewer::setEnableJumpToMultiPage (bool enable)
33+ {
34+ m_enableJumpToMultiPage = enable;
35+ if (!enable) {
36+ m_jumpToMultiPageButton->setVisible (false );
37+ }
38+ }
39+
3240void Viewer::onScaleFactorChanged (qreal factor)
3341{
3442 const auto text = QString::number (factor * 100 , ' f' , 2 ) + QLatin1Char (' %' );
@@ -52,6 +60,18 @@ void Viewer::onImageChanged(const QString &url)
5260 m_urlLabel->setToolTip (url);
5361 m_fileSizeLabel->setText (Utils::formatBytes (QFile (url).size ()));
5462
63+ m_jumpToMultiPageButton->setVisible (m_enableJumpToMultiPage
64+ && Utils::asynchronous<bool >([url]() {
65+ if (url.isEmpty ()) {
66+ return false ;
67+ }
68+ QImageReader reader (url);
69+ if (!reader.canRead ()) {
70+ return false ;
71+ }
72+ return reader.imageCount () > 1 ;
73+ }));
74+
5575 for (const auto &data : std::as_const (m_thumbnailList)) {
5676 if (data.fileInfo ().absoluteFilePath () == url) {
5777 return ;
@@ -61,11 +81,16 @@ void Viewer::onImageChanged(const QString &url)
6181 startImageLoadThread (url);
6282}
6383
84+ void Viewer::onJumpToMultiPage ()
85+ {
86+ emit jumpToMultiPage (m_urlLabel->text ());
87+ }
88+
6489QString Viewer::openImage ()
6590{
6691 const QString imageFilters (
67- tr (" Images (*.bmp *.gif *.jpg *.jpeg *.png *.svg *.tiff *.webp *.icns "
68- " *.bitmap *. graymap *.pixmap *.tga *.xbitmap *.xpixmap)" ));
92+ tr (" Images (*.bmp *.gif *.jpg *.jpeg *.png *.svg *.tiff *.webp *.ico *. icns *.bitmap "
93+ " *.graymap *.pixmap *.tga *.xbitmap *.xpixmap)" ));
6994 const auto path = QStandardPaths::standardLocations (QStandardPaths::PicturesLocation)
7095 .value (0 , QDir::homePath ());
7196 return QFileDialog::getOpenFileName (this , tr (" Open Image" ), path, imageFilters);
@@ -120,6 +145,14 @@ void Viewer::setupUI()
120145 gridLayout->addWidget (m_sizeLabel, 2 , 1 , 1 , 1 );
121146 gridLayout->addWidget (new QLabel (tr (" Scaling Ratio:" ), this ), 3 , 0 , 1 , 1 );
122147 gridLayout->addWidget (m_scaleLabel, 3 , 1 , 1 , 1 );
148+
149+ m_jumpToMultiPageButton = new QToolButton (this );
150+ sizePolicy = m_jumpToMultiPageButton->sizePolicy ();
151+ sizePolicy.setHorizontalPolicy (QSizePolicy::Preferred);
152+ m_jumpToMultiPageButton->setSizePolicy (sizePolicy);
153+ m_jumpToMultiPageButton->setText (tr (" Jump To Multi Page" ));
154+ m_jumpToMultiPageButton->hide ();
155+ connect (m_jumpToMultiPageButton, &QToolButton::clicked, this , &Viewer::onJumpToMultiPage);
123156}
124157
125158class ImageLoadRunnable ::ImageLoadRunnablePrivate
0 commit comments