| 754 | } |
| 755 | |
| 756 | QString pathTruncate(const QString& path, int depth) |
| 757 | { |
| 758 | if (path.isEmpty() || (depth < 0)) |
| 759 | return ""; |
| 760 | |
| 761 | QString trunc = QFileInfo(path).path(); |
| 762 | |
| 763 | if (pathDepth(trunc) > depth) { |
| 764 | return pathTruncate(trunc, depth); |
| 765 | } |
| 766 | |
| 767 | #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) |
| 768 | auto parts = QDir::toNativeSeparators(trunc).split(QDir::separator(), QString::SkipEmptyParts); |
| 769 | #else |
| 770 | auto parts = QDir::toNativeSeparators(trunc).split(QDir::separator(), Qt::SkipEmptyParts); |
| 771 | #endif |
| 772 | |
| 773 | if (parts.startsWith(".") && !path.startsWith(".")) { |
| 774 | parts.removeFirst(); |
| 775 | } |
| 776 | if (QDir::toNativeSeparators(path).startsWith(QDir::separator())) { |
| 777 | parts.prepend(""); |
| 778 | } |
| 779 | |
| 780 | trunc = parts.join(QDir::separator()); |
| 781 | |
| 782 | return trunc; |
| 783 | } |
| 784 | |
| 785 | QString ResolveExecutable(QString path) |
| 786 | { |