Skip to content

Commit

Permalink
Localize text stamps, tweak font/buffer size of text stamps a bit (#5602
Browse files Browse the repository at this point in the history
)

* Localize text stamps, tweak font/buffer size of text stamps a bit

* Fix iOS CI running out of space

* Same number of decimals, auto wrap lines

---------

Co-authored-by: Matthias Kuhn <matthias@opengis.ch>
  • Loading branch information
nirvn and m-kuhn authored Aug 31, 2024
1 parent c8b839a commit b4e3bc6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
with:
submodules: recursive

- name: Reclaim disk space
run: |
rm -rf /Applications/Xcode_14*
- name: 🌾 Prepare variables
id: vars
run: |
Expand Down
9 changes: 6 additions & 3 deletions src/core/utils/fileutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,17 +257,20 @@ void FileUtils::addImageStamp( const QString &imagePath, const QString &text )
painter.setRenderHint( QPainter::Antialiasing );

QFont font = painter.font();
const int pixelSize = std::min( img.width(), img.height() ) / 45;
font.setPixelSize( pixelSize );
font.setPixelSize( std::min( img.width(), img.height() ) / 40 );
font.setBold( true );

QgsRenderContext context = QgsRenderContext::fromQPainter( &painter );
QgsTextFormat format;
format.setFont( font );
format.setSize( font.pixelSize() );
format.setSizeUnit( Qgis::RenderUnit::Pixels );
format.setColor( Qt::white );
format.buffer().setColor( Qt::black );
format.buffer().setSize( 2 );
format.buffer().setSizeUnit( Qgis::RenderUnit::Pixels );
format.buffer().setEnabled( true );
QgsTextRenderer::drawText( QPointF( 10, img.height() - 10 ), 0, Qgis::TextHorizontalAlignment::Left, text.split( QStringLiteral( "\n" ) ), context, format );
QgsTextRenderer::drawText( QRectF( 10, 10, img.width() - 20, img.height() - 20 ), 0, Qgis::TextHorizontalAlignment::Left, text.split( QStringLiteral( "\n" ) ), context, format, true, Qgis::TextVerticalAlignment::Bottom, Qgis::TextRendererFlag::WrapLines );

img.save( imagePath, nullptr, 90 );

Expand Down
2 changes: 1 addition & 1 deletion src/qml/QFieldCamera.qml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Popup {
id: stampExpressionEvaluator

mode: ExpressionEvaluator.ExpressionMode
expressionText: "format_date(now(), 'yyyy-MM-dd @ HH:mm') || if(@gnss_coordinate is not null, format('\nLatitude %1 | Longitude %2 | Altitude %3 | Speed %4', coalesce(y(@gnss_coordinate), 'N/A'), coalesce(x(@gnss_coordinate), 'N/A'), coalesce(z(@gnss_coordinate), 'N/A'), if(@gnss_ground_speed != 'nan', @gnss_ground_speed || ' m/s', 'N/A')), '')"
expressionText: "format_date(now(), 'yyyy-MM-dd @ HH:mm') || if(@gnss_coordinate is not null, format('\n" + qsTr("Latitude") + " %1 | " + qsTr("Longitude") + " %2 | " + qsTr("Altitude") + " %3 | " + qsTr("Speed") + " %4', coalesce(format_number(y(@gnss_coordinate), 7), 'N/A'), coalesce(format_number(x(@gnss_coordinate), 7), 'N/A'), coalesce(format_number(z(@gnss_coordinate), 3) || ' m', 'N/A'), if(@gnss_ground_speed != 'nan', format_number(@gnss_ground_speed, 3) || ' m/s', 'N/A')), '')"

project: qgisProject
positionInformation: currentPosition
Expand Down

1 comment on commit b4e3bc6

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.