Commit Graph

265 Commits

Author SHA1 Message Date
Alessandro Portale
4d6827dde9 Utils: Tr::tr
Change-Id: Ic03e20993f05fb5b49a12c891d86afb2c8e18e08
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-02-01 13:48:22 +00:00
David Schulz
0dab651ccd Merge remote-tracking branch 'origin/9.0' into 10.0
Change-Id: I7e171601cd7317b48d5074bbc0ead127813d596c
2023-02-01 08:16:30 +01:00
Marcus Tillmanns
598ffc3b1c Utils: Fake root info
When trying to open a FileDialog all roots were tested for existence.
This is slow and might show ask-pass.

Since "/" can be considered always valid, we create a fake entry for it
and only test existence of remote paths if they are not a root path.

In the future FilePath should get a "isRoot()" function so we don't just
test for == "/".

Remove the fileAccess from WebAssembly devices.

Change-Id: I7a1a6e7d2025e9fd4428e4bd1d07cdbdb5680c8e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-27 11:13:58 +00:00
Marcus Tillmanns
7cb74e325f Utils: Add FilePath::copyRecursively
Change-Id: I0cb07158906a5e163ea35670f46f3b4fd9ec40b8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-01-25 07:29:52 +00:00
hjk
2ce413112b Utils: Push FilePath::toString border line a bit further
... in SaveFile

Change-Id: I80164853b8a756af8c74038b0375c423a6f500e2
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-01-13 09:50:11 +00:00
Eike Ziller
2688a9629c Merge remote-tracking branch 'origin/9.0'
Conflicts:
	src/libs/utils/pathchooser.cpp
	src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp

Change-Id: I7ae3f91618c4a4ccb088679caea72b2a81590960
2023-01-13 09:16:25 +01:00
hjk
516f1f12b6 Utils: Show hidden directories in non-native file dialog by default
Selecting .ssh/*.pub is tricky otherwise.

Change-Id: Icd26ec7e4bb6fbb348d62fe6f4a629ea2e723706
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-01-12 09:14:40 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Marcus Tillmanns
eca7044361 Utils: Add std::expected implementation
Adds a std::expected implementation that is compatible with >= C++11.

FilePath::fileContents and FilePath::writeFileContents as well as
FilePath::copyFile are changed to return std::expected.

A couple of macros have been added to aid in using the expected types.

An auto test was added showing how to use the library.

Change-Id: Ibe3aecfc1029a0cf13b45bf5184ff03a04a2393b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-12-14 10:39:29 +00:00
hjk
8e8afd3cf6 Utils: Remove FilePath::fromUrl()
Even though the concepts are similar, direct conversion is
usually neither desired (lossy) nor needed.

Change-Id: Id5c9e69d0597ed867cbda25f3fc4619a9fe90966
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-14 08:27:23 +00:00
Marcus Tillmanns
b3f82887a3 Utils: Change browse button to OptionPushButton
Allows the user to choose whether he wants to browse local files,
or remote files.

Change-Id: I0d262034a5c2df56bea2efca876c9019099e3da9
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-12-09 08:59:13 +00:00
hjk
e4c49b720e Utils: Consolidate the isRelative/isAbsolute implementations
Even if we do it wrong in corner cases, we should do it consistently.

Change-Id: I68d5a6e55ede889cb44bedb46d0ea545dae7ba2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-01 12:51:22 +00:00
Marcus Tillmanns
570a2f75ea Utils: Check shift pressed for directory chooser
Change-Id: I69e9ff2accf51ad7f6327b6708f114a0f87ada42
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-18 08:01:20 +00:00
Marcus Tillmanns
a22d62e57d Utils: Add FilePath::isSameFile()
FilePath::isSameFile() checks if two files are the same file.
It first checks if its on the same device. If it is, it will
try to read the fileId of the files and compare them.

Change-Id: I83668955cacd4e5ed03d43a3fee2be29e9d0a6f0
Reviewed-by: hjk <hjk@qt.io>
2022-10-13 11:25:48 +00:00
hjk
1fa3255242 Utils: Split off file access interface from IDevice
The file accessing functions form now a class hierarchy by themselves,
the devices return a suitable point.

The previous implementation was mildly confusing by the special handling
of the DesktopDevice, fallbacks and remote cases in the same function
leading to unnecessary boilerplate when adding new functions and
codepaths that sometimes passed the FilePath API twice.

Implemented are a "DesktopDeviceFileAccess" taking care of the
previous !needsDevice() branches and a "UnixDeviceFileAccess"
covering the current docker and RL uses.

As a side-effect this unifies to a large degree the current docker
and RL code paths with were occasionally deviating from each other
while they shouldn't.

Change-Id: I4ff59d4be2a07d13e2ca5e9ace26a84160a87c9d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-10-13 10:38:35 +00:00
Marcus Tillmanns
a0af1fa927 Utils: Keep User specified SideBar entries in file dialogs
Change-Id: I0b218e889f351a2dc635aca147b82d752ba85205
Reviewed-by: hjk <hjk@qt.io>
2022-10-12 13:41:09 +00:00
Marcus Tillmanns
34fbf6261a FileUtils:: Support non-native filedialog
Change-Id: I71797a31c58f0870a95ac396404721b004741115
Reviewed-by: hjk <hjk@qt.io>
2022-10-12 12:43:28 +00:00
hjk
e8eaf7809b Utils: Don't crash on empty 'find' output
Change-Id: I772718d882ac7744c4f955190b038cd1e78f347d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-10-12 12:24:11 +00:00
hjk
b1471fe61f Utils: Combine some of the iterateWithFind overloads
Change-Id: I668447d0049f2e35cd0c76d2c5708779196167ec
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-10-12 08:59:32 +00:00
Marcus Tillmanns
ae58d373b0 Add FSEngine FilePath Cache
To speed up file dialogs we introduce a 1 minute cache for
the FilePathInfo.

A new version of "IDevice::iterateDirectories" allows implementations to
provide the FilePathInfo directly.

DockerDevice implements fetching the filePathInfo during
iterateDirectories which greatly improves the speed again.

Change-Id: I24ac16adb2478cbf16a22012e72fcb8910dcdac5
Reviewed-by: hjk <hjk@qt.io>
2022-10-11 08:53:02 +00:00
hjk
63faccdb7c Utils: Implement ls-based subdir iteration
Needed when 'find' does not work as expected.

Change-Id: Ifbe762590ad2a6339152ed728e4d72820b4eae91
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-10 10:06:24 +00:00
hjk
5dde520a43 Utils: Return a bit more data from DeviceShell::runInShell
Pass on stderr data and exit code to the caller, it's typically
in a better condition to handle errors.

Use it to notify the user about non-available 'find' arguments
and fix the fallback to ls-based operation.

Change-Id: I535535de2ffa09cad1dd6e9b07eb69f807dbae2f
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-10 08:39:55 +00:00
hjk
e0d81084a9 Utils: Fix find logic
We are more interested in the files than the error message.

Task-number: QTCREATORBUG-28242
Change-Id: Ifc5724764797d2488c7fa231ff5b1cf2292418ed
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-07 13:25:33 +00:00
hjk
714e6f5c8f Utils: Make more unix find code re-usable
Change-Id: I8fe95158ed77c8f9fb8c86a8e813b5c5de425b8a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-07 11:08:52 +00:00
hjk
dd585c601c Utils: Make path cleaning platform agnostic
Unfortunately, QDir::cleanPath() only cleans according to the rules
of the host system, which can be wrong in remote setups.

As the implementation is not accessible/tweakable from the outside,
copy the relevant code and remove the platform #ifdef's.

Change-Id: Ife9a925412a12d3cef21ed3721a387c61c152ddf
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-23 09:25:05 +00:00
Eike Ziller
5d55cfdae5 Merge remote-tracking branch 'origin/8.0'
Conflicts:
	share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/HelperWidgets/ColorEditor.qml
	share/qtcreator/qmldesigner/propertyEditorQmlSources/imports/StudioTheme/icons.ttf
	src/libs/utils/fileutils.cpp
	src/plugins/qmldesigner/components/edit3d/edit3dwidget.cpp
	src/plugins/qmldesigner/designercore/include/abstractview.h
	src/plugins/qmldesigner/designercore/include/nodemetainfo.h
	src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp
	src/plugins/qmldesigner/designercore/model/model_p.h
	src/plugins/remotelinux/linuxdevice.cpp
	tests/auto/utils/fileutils/tst_fileutils.cpp

Change-Id: I26a21e2523d3d725fdb8c548a531cdbdaeaeca20
2022-09-19 09:54:06 +02:00
Marcus Tillmanns
ed46f1f002 linuxdevice: Fix ::bytesAvailable
DeviceShell does not support piping commands at the moment.

To continue to support ::bytesAvailable the parsing of the
output from "df" is moved to FileUtils::bytesAvailableFromDFOutput.

Change-Id: Ia229208748aa6c572b99899e6ae042bdd5654f4a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-09-15 05:21:52 +00:00
Eike Ziller
2c51e4bc17 FilePath: Return optional bytearray for file contents
For differentiating between "error" and "empty file".

Change-Id: I2c019ceac625e7be3180afa4d47ae3a24df91c1d
Reviewed-by: hjk <hjk@qt.io>
2022-09-12 11:57:04 +00:00
hjk
7cfc3d26bc Utils: Replace FilePath part setters
... by a combined version. This will make it easier to store the parts
in one QString object.

Change-Id: Ie85a77e3957c78a30e49998fe2e617af35a8ad17
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-01 07:59:29 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
hjk
11648298c8 Utils: Port some FilePath part accessors to QStringView
Change-Id: Ib5cc262e44c73880b6538eed714365e3d685870a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-08-22 13:27:56 +00:00
Eike Ziller
74a986b350 FileUtils: Fix sdktool build against 5.15
Change-Id: Ieb9cc8baa684008a5ad1db28648870715f8db0d7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-08-22 08:11:01 +00:00
Marcus Tillmanns
04205d1225 FileUtils: Adds toFilePathList function
Change-Id: Ie3137751135fdb6c3161cc886f307323fcce6b72
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-08-04 11:33:53 +00:00
Marcus Tillmanns
783f0e1205 filepath: Move FileUtils:: function out of FilePath.cpp
Change-Id: If78c349b0145b86a76cd033e4dbc30b237ad917b
Reviewed-by: hjk <hjk@qt.io>
2022-08-04 08:01:59 +00:00
Alessandro Portale
ce7a761075 Utils: Improve FileUtils::commonPath
Make it a worthy FilePath-based counterpart of Utils::commonPath.
With tests.

Change-Id: I68bae129c5d9d9dd3e46dfa6093e229f8ca0aee1
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-07-29 20:20:22 +00:00
hjk
e1a63ce928 FileUtils: Pass parent to file dialog
Change-Id: Ibbda132136215e34e078b943ac9909e42113643b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-07-27 14:34:36 +00:00
Marcus Tillmanns
3462bc67be filesystem: Add QFSEngine for filepaths
Change-Id: Ibd0c88c69863c0877138d8cc45541530c359bd9c
Reviewed-by: hjk <hjk@qt.io>
2022-07-21 13:14:01 +00:00
Jarek Kobus
a67aee30a6 Utils: More forward declarations / drop unused headers [S]
Round 1 - focus on headers.
For classes with initial in range [S].
Try to keep the same separators between different kind of headers.

SmallString[xxx] classes skipped for now.

Change-Id: Ie5c8edcb028e33eb8f9619e646afc462b91dca73
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:19:00 +00:00
Jarek Kobus
2853660a59 Utils: More forward declarations / drop unused headers [D-G]
Round 1 - focus on headers.
For classes with initial in range [D-G].
Try to keep the same separators between different kind of headers.

Change-Id: Id42cd7b3743a816f75cecb6b576c0e37cb057473
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:13:52 +00:00
Jarek Kobus
0a8dbaf153 Utils lib: Remove unneeded includes from cpp files
It's a result of a team work consisting of yellow triangle and me.

Change-Id: I8b4812766da70e0785ae71bf0cb71357379e2514
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-05-19 12:37:20 +00:00
hjk
f7a585fad9 FileUtils: Add some helper to handle ls-style output
Unix-ish device implementations would otherwise repeat that code.

Change-Id: I1265fe1a69e55409ab2875d0b6f6113ec92edd79
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-02-15 08:57:19 +00:00
hjk
8885ef7e5a Utils: Pass dialog parent to Utils::* file dialog
Amends 3edc5673b5.

Turns out quite a few potential uses have other parents than
ICore::dialogParent().

Use a nullptr parent to mean ICore::dialogParent() to keep the
caller side simple.

Change-Id: Icfe1daafd710ae273d286679e0c8e2a3a27da552
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-17 12:54:08 +00:00
hjk
2ab2d96753 Utils: Use FilePath in copy helpers
Change-Id: I81b367a5851c0fbcdf45c63c5536c206845a8337
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-10 07:19:10 +00:00
hjk
f1b45ca775 Utils: Make FileSaver somewhat work for remote files
Write to a local file first, transfer content when finalizing.

Change-Id: I4740838e049f5a556e286b2a8944634ff7d2b0c7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-08-04 12:49:39 +00:00
hjk
3edc5673b5 Utils: Provide FilePath based wrappers for common dialogs
Change-Id: I464a7b5775495f32648905335f2d798384867900
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-26 09:44:20 +00:00
Christian Stenger
a0da3ce69f Utils: Move filterEntriesHelper() out of FilePath
Currently only used inside DockerDevice and it fails to build
when building sdktool with old Qt which is still necessary.

Change-Id: Ic48414f0cb8f0955e7561f7484e3ea1c726c816a
Reviewed-by: hjk <hjk@qt.io>
2021-07-22 12:49:45 +00:00
hjk
fd677101a9 Utils: Split FilePath off fileutils.h
This now rather central class deserves a suitably named file(pair).

The rarer used declarations including otherwise not needed includes are
still in fileutils.h.

Change-Id: Ib18d72f16322c03f76023fdefcd5f6da35311b8b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-22 11:52:58 +00:00
hjk
486fd8f7d6 Docker: Implement fallback for DockerDevice::directoryEntries()
Change-Id: I57430bc4cf79abfc07ccbe06746a0857e10053da
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-16 14:37:15 +00:00
hjk
1bde4ddbec ProjectExplorer: Use FilePaths in project tree nodes
Change-Id: I31b15c428d9b962333947b1e32641fd80f61d069
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-16 13:45:06 +00:00
hjk
d06c670504 Utils: Introduce a FilePath::withNewPath() convenience method
It's effectively the mirrored version of onDevice() with an
equally odd name which is a bit more straightforward to use
in some cases.

Change-Id: I0cfedeb58871a857c93144e2a0d734bad1bcd887
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-16 11:13:14 +00:00