FS#13979 - rbutil: fix Talk file exclusion options and initial focus (Alessio Lenzi)

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]>
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 612453da482c20a61303a36479287a7e19c2bc74
Author: Solomon Peachy <[email protected]>
Date:   Mon Aug 10 11:05:44 2026 -0400

    FS#13979 - rbutil: fix Talk file exclusion options and initial focus (Alessio Lenzi)
    
    1. The "Ignore files" checkbox was saved in the settings but not
       consulted when starting generation. Patterns from the text field were
       therefore applied even when the checkbox was unchecked. The pattern list
       is now passed to TalkFileCreator only when the option is enabled.
    
    2. Ignore patterns were converted to regular expressions by replacing only
       '*' and '?'. Other regular-expression characters were left unescaped and
       matches were not properly bounded. The patch uses Qt's
       wildcardToRegularExpression() conversion instead.
    
    3. The Talk generation dialog initially focused "Strip Extensions" because of
       widget creation order. It now explicitly focuses the folder tree, matching
       the task flow and making keyboard and screen-reader use more predictable.
    
    4. The handling of talkclips.ignore is also corrected so that files below a
       marked directory are skipped recursively. Previously Rockbox Utility could
       generate talkclips.ignore.talk and clips for files below .rockbox even though
       .rockbox/talkclips.ignore was present.
    
    Change-Id: I1f9f14ed7fc057bc254f62148a7ef8ffb69425ed

diff --git a/utils/rbutilqt/base/talkfile.cpp b/utils/rbutilqt/base/talkfile.cpp
index 3cd265b7f1..40ceb03158 100644
--- a/utils/rbutilqt/base/talkfile.cpp
+++ b/utils/rbutilqt/base/talkfile.cpp
@@ -137,6 +137,20 @@ bool TalkFileCreator::createTalkList(QDir startDir)
     LOG_INFO() << "generating list of files" << startDir;
     m_talkList.clear();
 
+    const QString startPath = QDir::cleanPath(startDir.absolutePath());
+    auto isInIgnoredDirectory = [&startPath](const QFileInfo& fileInfo) {
+        QDir dir(fileInfo.isDir() ? fileInfo.absoluteFilePath()
+                                  : fileInfo.absolutePath());
+        while(true) {
+            if(QFileInfo::exists(dir.filePath("talkclips.ignore")))
+                return true;
+
+            if(QDir::cleanPath(dir.absolutePath()) == startPath || !dir.cdUp())
+                break;
+        }
+        return false;
+    };
+
      // create Iterator
     QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags;
     if(m_recursive)
@@ -160,6 +174,10 @@ bool TalkFileCreator::createTalkList(QDir startDir)
 
         QFileInfo fileInf = it.fileInfo();
 
+        // A talkclips.ignore file excludes its directory and all descendants.
+        if(isInIgnoredDirectory(fileInf))
+            continue;
+
         // its a dir
         if(fileInf.isDir())
         {
@@ -168,12 +186,6 @@ bool TalkFileCreator::createTalkList(QDir startDir)
             // insert into List
             if(!dir.dirName().isEmpty() && m_talkFolders)
             {
-                // check if we should ignore it
-                if(QFileInfo::exists(dir.path() + "/talkclips.ignore"))
-                {
-                    continue;
-                }
-
                 // check to see if it's already covered
                 if(m_generateOnlyNew && QFileInfo::exists(dir.path() + "/_dirname.talk"))
                 {
@@ -209,8 +221,8 @@ bool TalkFileCreator::createTalkList(QDir startDir)
                 bool match = false;
                 for(int i=0; i < m_ignoreFiles.size();i++)
                 {
-                    QString pattern = m_ignoreFiles[i].trimmed()
-                                        .replace("?", ".").replace("*", ".*");
+                    QString pattern = QRegularExpression::wildcardToRegularExpression(
+                            m_ignoreFiles[i].trimmed());
                     QRegularExpression rx(pattern);
                     if(rx.match(fileInf.fileName()).hasMatch())
                         match = true;
diff --git a/utils/rbutilqt/installtalkwindow.cpp b/utils/rbutilqt/installtalkwindow.cpp
index d5cd8c76f3..be6c93b1fb 100644
--- a/utils/rbutilqt/installtalkwindow.cpp
+++ b/utils/rbutilqt/installtalkwindow.cpp
@@ -46,6 +46,7 @@ InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
     ui.treeView->setHeaderHidden(true);
 
     updateSettings();
+    ui.treeView->setFocus(Qt::OtherFocusReason);
 }
 
 
@@ -116,7 +117,9 @@ void InstallTalkWindow::accept()
     talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
     talkcreator->setTalkFolders(ui.talkFolders->isChecked());
     talkcreator->setTalkFiles(ui.talkFiles->isChecked());
-    talkcreator->setIgnoreFiles(ui.ignoreFiles->text().split(",", Qt::SkipEmptyParts));
+    talkcreator->setIgnoreFiles(ui.ignoreEnabled->isChecked()
+            ? ui.ignoreFiles->text().split(",", Qt::SkipEmptyParts)
+            : QStringList());
 
     connect(talkcreator, &TalkFileCreator::done, logger, &ProgressLoggerGui::setFinished);
     connect(talkcreator, &TalkFileCreator::logItem, logger, &ProgressLoggerGui::addItem);
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.