Skip to content

Comments

Fixed windows photo attachment and refactored input functions#4310

Open
gabriel-bolbotina wants to merge 11 commits intomasterfrom
fix/windows-photo-attaching
Open

Fixed windows photo attachment and refactored input functions#4310
gabriel-bolbotina wants to merge 11 commits intomasterfrom
fix/windows-photo-attaching

Conversation

@gabriel-bolbotina
Copy link
Contributor

@gabriel-bolbotina gabriel-bolbotina commented Feb 9, 2026

Ready for review.

Modified the image paths in components that used them from 'file://' to 'file:///', which works on all the platforms, both Windows and Unix based.

I refactored the input functions that deal with paths to better accommodate system based differences for handling paths (e.g., partition letters on Windows). Also, I tried to use QDir and QFileInfo as much as possible.

Tested adding, viewing and saving photos on:

  • Windows
  • MacOS
  • iOS
  • android
video-window-photo-fix.mov

Also ran the testUtils and testSketching on Windows as well.

@gabriel-bolbotina gabriel-bolbotina linked an issue Feb 9, 2026 that may be closed by this pull request
@gabriel-bolbotina gabriel-bolbotina marked this pull request as ready for review February 9, 2026 12:55
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build 📬 Mergin Maps 63041 dmg Expires: 10/05/2026 #6304
linux Build 📭 Build not yet complete or failed.
win64 Build 📬 Mergin Maps 54971 win64 Expires: 10/05/2026 #5497
Android Build 📭 Build not yet complete or failed.
iOS Build 📬 Build number: 26.02.855511 #8555

Copy link
Contributor

@Withalion Withalion left a comment

Choose a reason for hiding this comment

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

Nice this will be great UX improvement. Just a few bits here and there, which I'm not sure myself

@Withalion
Copy link
Contributor

In testing we should also check if it fixes:

@github-actions
Copy link

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build 📭 Build not yet complete or failed.
linux Build 📭 Build not yet complete or failed.
win64 Build 📬 Mergin Maps 55731 win64 Expires: 19/05/2026 #5573
Android Build 📭 Build not yet complete or failed.
iOS Build 📭 Build not yet complete or failed.

Copy link
Contributor

@Withalion Withalion left a comment

Choose a reason for hiding this comment

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

Multiple thinks to think about, but we are on a right path

Copy link
Contributor

Choose a reason for hiding this comment

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

I would replace all QLatin1Char that you used with QStringLiteral

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think QLatin1Char is more efficient in this case because it does not create a whole Qstring object and it is used only for a character.
Are there any benefits to changing them to QStringLiteral in the modified functions?

Copy link
Contributor

Choose a reason for hiding this comment

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

After reading the documentation it doesn't look like it's that straight forward. This part talks mostly about what we are discussing. However I would like to highlight one thing in the beginning:

Generally, QString can be used everywhere and it will perform fine.

@github-actions
Copy link

📦 Build Artifacts Ready

OS Status Build Info Workflow run
macOS Build 📬 Mergin Maps 63851 dmg Expires: 21/05/2026 #6385
linux Build 📭 Build not yet complete or failed.
win64 Build 📬 Mergin Maps 55801 win64 Expires: 21/05/2026 #5580
Android Build 📬 Mergin Maps 769551 APK [arm64-v8a] Expires: 21/05/2026 #7695
Android Build 📬 Mergin Maps 769511 APK [armeabi-v7a] Expires: 21/05/2026 #7695
iOS Build 📭 Build not yet complete or failed.

Copy link
Contributor

@Withalion Withalion left a comment

Choose a reason for hiding this comment

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

Just some small changes to strings as we discussed

str = QStringLiteral( "/complex/valid/Φ!l@#äme$%^&()-_=+[]{}`~;',.ext" );
InputUtils::sanitizePath( str );
QCOMPARE( str, QStringLiteral( "/complex/valid/Φ!l@#äme$%^&()-_=+[]{}`~;',.ext" ) );
QCOMPARE( str, QStringLiteral( "/complex/valid/Φ!l@_äme$%^&()-_=+[]{}`~;',.ext" ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please note down somewhere that # is prohibited character now

Copy link
Contributor

Choose a reason for hiding this comment

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

After reading the documentation it doesn't look like it's that straight forward. This part talks mostly about what we are discussing. However I would like to highlight one thing in the beginning:

Generally, QString can be used everywhere and it will perform fine.

QString relativePath = prefixDir.relativeFilePath( cleanPath );

// check if the path starts with ".." or is absolute (on Windows/different drives), it's not a "child"
if ( relativePath.startsWith( QLatin1String( ".." ) ) || QDir::isAbsolutePath( relativePath ) )
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ( relativePath.startsWith( QLatin1String( ".." ) ) || QDir::isAbsolutePath( relativePath ) )
if ( relativePath.startsWith( QLatin1StringView( ".." ) ) || QDir::isAbsolutePath( relativePath ) )

QLatin1String is a synonym for QLatin1StringView, but it's softly deprecated

);
if ( reservedNames.match( base.trimmed() ).hasMatch() )
{
base = base.trimmed() + QLatin1Char( '_' );
Copy link
Contributor

Choose a reason for hiding this comment

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

this will get changed to QChar

// reassemble
if ( !suffix.isEmpty() )
{
return base + QLatin1Char( '.' ) + suffix;
Copy link
Contributor

Choose a reason for hiding this comment

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

this will also get changed to QChar

Comment on lines +2013 to +2014
QUrl url = QUrl::fromUserInput( cleanPath );
bool isUrl = path.startsWith( QLatin1String( "file:" ), Qt::CaseInsensitive );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
QUrl url = QUrl::fromUserInput( cleanPath );
bool isUrl = path.startsWith( QLatin1String( "file:" ), Qt::CaseInsensitive );
const QUrl url = QUrl::fromUserInput( cleanPath );
const bool isUrl = path.startsWith( QStringLiteral( "file:" ), Qt::CaseInsensitive );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to attach or view photos in Windows app

2 participants