Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## v2.2.1

- [#17](https://github.com/procitec/qlitehtmlbrowser/issues/17): Scale changed signal
- [#22](https://github.com/procitec/qlitehtmlbrowser/issues/22): Scaling makes images blurry with css properties `width`

## v2.2.0

- [#20](https://github.com/procitec/qlitehtmlbrowser/issues/20): Feature Search Text
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.28)

project( QLiteHtmlBrowser VERSION 2.2.0 )
project( QLiteHtmlBrowser VERSION 2.2.1 )

include(GNUInstallDirs)

Expand Down
4 changes: 4 additions & 0 deletions include/qlitehtmlbrowser/QLiteHtmlBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ public Q_SLOTS:
/// send when an anchor is clicked in the document, even if link is not activated, @see setOpenLinks
void anchorClicked( const QUrl& );

/// send when scale changes
void scaleChanged();

protected:
private:
QLiteHtmlBrowserImpl* mImpl = nullptr;
};
1 change: 1 addition & 0 deletions src/QLiteHtmlBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ QLiteHtmlBrowser::QLiteHtmlBrowser( QWidget* parent )

connect( mImpl, &QLiteHtmlBrowserImpl::urlChanged, this, &QLiteHtmlBrowser::sourceChanged );
connect( mImpl, &QLiteHtmlBrowserImpl::anchorClicked, this, &QLiteHtmlBrowser::anchorClicked );
connect( mImpl, &QLiteHtmlBrowserImpl::scaleChanged, this, &QLiteHtmlBrowser::scaleChanged );
}

QUrl QLiteHtmlBrowser::source() const
Expand Down
1 change: 1 addition & 0 deletions src/QLiteHtmlBrowserImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ QLiteHtmlBrowserImpl::QLiteHtmlBrowserImpl( QWidget* parent )

shortcut = new QShortcut( QKeySequence{ QKeySequence::Back }, this );
connect( shortcut, &QShortcut::activated, this, &QLiteHtmlBrowserImpl::backward );
connect( mContainer, &container_qt::scaleChanged, this, &QLiteHtmlBrowserImpl::scaleChanged );

auto* layout = new QVBoxLayout;
layout->setContentsMargins( 0, 0, 0, 0 );
Expand Down
1 change: 1 addition & 0 deletions src/QLiteHtmlBrowserImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class QLiteHtmlBrowserImpl : public QWidget
/// emited when the url changed due to user interaction, e.g. link activation
void urlChanged( const QUrl& );
void anchorClicked( const QUrl& );
void scaleChanged();

private:
class HistoryEntry
Expand Down
4 changes: 2 additions & 2 deletions src/container_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void container_qt::draw_list_marker( litehtml::uint_ptr hdc, const litehtml::lis
{
auto url = resolveUrl( marker.image.c_str(), marker.baseurl );
auto image = load_pixmap( url );
p->drawPixmap( /*scaled*/ ( QRect( marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height ) ), image );
p->drawPixmap( QRect( marker.pos.x, marker.pos.y, marker.pos.width, marker.pos.height ), image );
}
else
{
Expand Down Expand Up @@ -537,7 +537,6 @@ void container_qt::draw_background( litehtml::uint_ptr hdc, const std::vector<li
{
// qDebug() << "draw_background: image" << bg.image_size.width << bg.image_size.height;
// qDebug() << "draw_background: pixmap" << pm.width() << pm.height();
pm = pm.scaled( bg.image_size.width, bg.image_size.height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
p->drawPixmap( QRect( bg.position_x, bg.position_y, bg.image_size.width, bg.image_size.height ), pm );
}
break;
Expand Down Expand Up @@ -874,6 +873,7 @@ void container_qt::setScale( double scale )
findText( mFindText );
horizontalScrollBar()->setValue( std::floor( relH * horizontalScrollBar()->maximum() ) );
verticalScrollBar()->setValue( std::floor( relV * verticalScrollBar()->maximum() ) );
emit scaleChanged();
}

void container_qt::get_media_features( litehtml::media_features& media ) const
Expand Down
1 change: 1 addition & 0 deletions src/container_qt.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class container_qt : public QAbstractScrollArea, protected litehtml::document_co

Q_SIGNALS:
void anchorClicked( const QUrl& );
void scaleChanged();

protected:
litehtml::uint_ptr create_font(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions test/browser/files/images_01/index-csswidth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!DOCTYPE html>
<html>
<head>
<title>Images Demo</title>
</head>
<body>

<div>
<p>Image without css width:</p>
<img src="images/procitec_text.png"/>
</div>

<div>
<p>Image with 50% css width:</p>
<img src="images/go2signals keyvisual neu.png" style="width: 50%;"/>
</div>


<div>
<p>Image with 100px width:</p>
<img src="images/go2signals keyvisual neu.png" style="width: 100px;"/>
</div>


<div>
<p>Image with 100% css width:</p>
<img src="images/procitec_info.png" style="width: 100%;"/>
</div>


</body>
</html>


10 changes: 10 additions & 0 deletions test/browser/testbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <QtGui/QPdfWriter>
#include <QtCore/QDebug>
#include <QtWidgets/QStyle>
#include <QtWidgets/QStatusBar>
#include <cmath>

TestBrowser::TestBrowser()
{
Expand Down Expand Up @@ -99,6 +101,14 @@ TestBrowser::TestBrowser()
mHelpEngine = new QHelpEngine( collectionFile );
mHelpEngine->setupData();
mBrowser->setHelpEnginge( mHelpEngine );

auto* statusbar = statusBar();
mScale = new QLabel();
mScale->setText( mScaleText.arg( static_cast<int>( std::round( mBrowser->scale() * 100.0 ) ) ) );
statusbar->addPermanentWidget( mScale );

connect( mBrowser, &QHelpBrowser::scaleChanged, this,
[this]() { mScale->setText( mScaleText.arg( static_cast<int>( std::round( mBrowser->scale() * 100.0 ) ) ) ); } );
}

TestBrowser::~TestBrowser()
Expand Down
4 changes: 4 additions & 0 deletions test/browser/testbrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QLabel>
#include <QAction>
#include <QtCore/QStringList>
#include <QtCore/QDir>
#include <QtHelp/QHelpEngine>

Expand Down Expand Up @@ -49,4 +51,6 @@ class TestBrowser : public QMainWindow
QHelpEngine* mHelpEngine = nullptr;
QAction* mNextFindMatch = nullptr;
QAction* mPreviousFindMatch = nullptr;
QLabel* mScale = nullptr;
QString mScaleText = tr( "Zoom: %1%" );
};