Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP5
kstars
fix-placeholder-path-part2.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-placeholder-path-part2.patch of Package kstars
From 1530d9eec6140b53bace3cb5afda8c831834c89c Mon Sep 17 00:00:00 2001 From: Jasem Mutlaq <mutlaqja@ikarustech.com> Date: Mon, 6 Feb 2023 18:25:12 +0300 Subject: [PATCH] Fix placeholder sequence counter on Windows. BUGS:465364 FIXED-IN:3.6.3 --- kstars/auxiliary/ksutils.cpp | 4 ++-- kstars/ekos/capture/capture.cpp | 8 +++----- kstars/ekos/capture/placeholderpath.cpp | 27 +++++++++++++++++++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/kstars/auxiliary/ksutils.cpp b/kstars/auxiliary/ksutils.cpp index 664bbcca8..a9e37efac 100644 --- a/kstars/auxiliary/ksutils.cpp +++ b/kstars/auxiliary/ksutils.cpp @@ -1120,7 +1120,7 @@ QString getDefaultPath(const QString &option) if (option == "fitsDir") { - return QDir::homePath(); + return QDir::toNativeSeparators(QDir::homePath()); } else if (option == "indiServer") { @@ -1134,7 +1134,7 @@ QString getDefaultPath(const QString &option) else if (option == "PlaceholderFormat") { #if defined(Q_OS_WIN) - return "\%t\%T\%F\%t_%T_%F"; + return "\\%t\\%T\\%F\\%t_%T_%F"; #else return "/%t/%T/%F/%t_%T_%F"; #endif diff --git a/kstars/ekos/capture/capture.cpp b/kstars/ekos/capture/capture.cpp index 79fdbeab7..2d758f804 100644 --- a/kstars/ekos/capture/capture.cpp +++ b/kstars/ekos/capture/capture.cpp @@ -444,7 +444,7 @@ Capture::Capture() fileDirectoryT->setText(Options::captureDirectory()); else { - fileDirectoryT->setText(QDir::homePath() + QDir::separator() + "Pictures"); + fileDirectoryT->setText(QDir::toNativeSeparators(QDir::homePath() + "/Pictures")); Options::setCaptureDirectory(fileDirectoryT->text()); } @@ -3741,13 +3741,11 @@ void Capture::syncTelescopeInfo() void Capture::saveFITSDirectory() { QString dir = - QFileDialog::getExistingDirectory(Manager::Instance(), i18nc("@title:window", "FITS Save Directory"), - dirPath.toLocalFile()); - + QFileDialog::getExistingDirectory(Manager::Instance(), i18nc("@title:window", "FITS Save Directory"), dirPath.toLocalFile()); if (dir.isEmpty()) return; - fileDirectoryT->setText(dir); + fileDirectoryT->setText(QDir::toNativeSeparators(dir)); } void Capture::loadSequenceQueue() diff --git a/kstars/ekos/capture/placeholderpath.cpp b/kstars/ekos/capture/placeholderpath.cpp index 2632121d6..97926b514 100644 --- a/kstars/ekos/capture/placeholderpath.cpp +++ b/kstars/ekos/capture/placeholderpath.cpp @@ -316,7 +316,7 @@ QString PlaceholderPath::generateFilename(const QString &directory, if (batch_mode) currentDir = directory; else - currentDir = KSPaths::writableLocation(QStandardPaths::TempLocation) + QDir::separator() + "kstars" + QDir::separator(); + currentDir = QDir::toNativeSeparators(KSPaths::writableLocation(QStandardPaths::TempLocation) + "/kstars/"); QString tempFormat = currentDir + format + "_%s" + QString::number(formatSuffix); @@ -324,7 +324,12 @@ QString PlaceholderPath::generateFilename(const QString &directory, QRegularExpression // This is the original regex with %p & %d tags - disabled for now to simply // re("(?<replace>\\%(?<name>(filename|f|Datetime|D|Type|T|exposure|e|Filter|F|target|t|sequence|s|directory|d|path|p))(?<level>\\d+)?)(?<sep>[_/])?"); +#if defined(Q_OS_WIN) + re("(?<replace>\\%(?<name>(filename|f|Datetime|D|Type|T|exposure|e|Filter|F|target|t|sequence|s))(?<level>\\d+)?)(?<sep>[_\\\\])?"); +#else re("(?<replace>\\%(?<name>(filename|f|Datetime|D|Type|T|exposure|e|Filter|F|target|t|sequence|s))(?<level>\\d+)?)(?<sep>[_/])?"); +#endif + while ((i = tempFormat.indexOf(re, i, &match)) != -1) { QString replacement = ""; @@ -408,6 +413,7 @@ QString PlaceholderPath::generateFilename(const QString &directory, } else qWarning() << "Unknown replacement string: " << match.captured("replace"); + if (replacement.isEmpty()) tempFormat = tempFormat.replace(match.capturedStart(), match.capturedLength(), replacement); else @@ -442,7 +448,11 @@ QStringList PlaceholderPath::remainingPlaceholders(const QString &filename) { QList<QString> placeholders = {}; QRegularExpressionMatch match; - QRegularExpression re("(?<replace>\\%(?<name>[a-z])(?<level>\\d+)?)(?<sep>[_/])?"); +#if defined(Q_OS_WIN) + QRegularExpression re("(?<replace>\\%(?<name>[a-zA-Z])(?<level>\\d+)?)(?<sep>[_\\\\])+"); +#else + QRegularExpression re("(?<replace>%(?<name>[a-zA-Z])(?<level>\\d+)?)(?<sep>[_/])+"); +#endif int i = 0; while ((i = filename.indexOf(re, i, &match)) != -1) { @@ -456,11 +466,20 @@ QStringList PlaceholderPath::remainingPlaceholders(const QString &filename) QList<int> PlaceholderPath::getCompletedFileIds(const SequenceJob &job, const QString &targetName) { QString path = generateFilename(job, targetName, true, true, 0, ".*", "", true); - QFileInfo path_info(path); + auto sanitizedPath = path; + + // This is needed for Windows as the regular expression confuses path search + QString regexp = "(?<id>\\d+).*"; + sanitizedPath.remove(regexp); + QFileInfo path_info(sanitizedPath); QDir dir(path_info.dir()); + + // e.g. Light_R_(?<id>\\d+).* + QString glob = path_info.fileName() + regexp; + QStringList matchingFiles = dir.entryList(QDir::Files); QRegularExpressionMatch match; - QRegularExpression re("^" + path_info.fileName() + "$"); + QRegularExpression re("^" + glob + "$"); QList<int> ids = {}; for (auto &name : matchingFiles) { -- GitLab
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor