[frameworks/kio] src/filewidgets: knewfilemenu: minor fixes

Antti Savolainen <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 72471c2f8702f87cb1b8f9b64c5159a445760c30 by Antti Savolainen.
Committed on 31/07/2026 at 16:12.
Pushed by asavolainen into branch 'master'.

knewfilemenu: minor fixes

M  +8    -13   src/filewidgets/knewfilemenu.cpp

https://invent.kde.org/frameworks/kio/-/commit/72471c2f8702f87cb1b8f9b64c5159a445760c30

diff --git a/src/filewidgets/knewfilemenu.cpp b/src/filewidgets/knewfilemenu.cpp
index bb444f223b..b9876d0e31 100644
--- a/src/filewidgets/knewfilemenu.cpp
+++ b/src/filewidgets/knewfilemenu.cpp
@@ -30,7 +30,6 @@
 #include <KCollapsibleGroupBox>
 #include <KConfigGroup>
 #include <KDesktopFile>
-#include <KDirOperator>
 #include <KDirWatch>
 #include <KFileUtils>
 #include <KIconDialog>
@@ -51,14 +50,12 @@
 #include <QLabel>
 #include <QLineEdit>
 #include <QList>
-#include <QLoggingCategory>
 #include <QMenu>
 #include <QMimeDatabase>
 #include <QPushButton>
 #include <QStandardPaths>
 #include <QTemporaryFile>
 #include <QTimer>
-#include <QVBoxLayout>
 
 #ifdef Q_OS_WIN
 #include <sys/utime.h>
@@ -135,7 +132,7 @@ public:
         QMimeType mimeType; /// Mimetype that the icon and comment are derived from
         QIcon icon; /// The icon displayed in the context menu
 
-        bool parseFile(QString file);
+        bool parseFile(const QString &file);
     };
 
     /*
@@ -159,16 +156,16 @@ QDebug operator<<(QDebug debug, const KNewFileMenuSingleton::Entry &Entry)
     debug.nospace() << "url\t\t" << Entry.url << "\n";
     debug.nospace() << "key\t\t" << Entry.key << "\n";
     debug.nospace() << "text\t\t" << Entry.text << "\n";
-    debug.nospace() << "filepath\t" << Entry.sourceFileInfo << "\n";
-    debug.nospace() << "templatepath\t" << Entry.templatePath << "\n";
+    debug.nospace() << "sourceFileInfo\t" << Entry.sourceFileInfo << "\n";
+    debug.nospace() << "templatePath\t" << Entry.templatePath << "\n";
     debug.nospace() << "comment\t\t" << Entry.comment << "\n";
-    debug.nospace() << "mimetype\t" << Entry.mimeType << "\n";
+    debug.nospace() << "mimeType\t" << Entry.mimeType << "\n";
     debug.nospace() << "icon\t\t" << Entry.icon << "\n";
 
     return debug;
 }
 
-bool KNewFileMenuSingleton::Entry::parseFile(QString file)
+bool KNewFileMenuSingleton::Entry::parseFile(const QString &file)
 {
     QMimeDatabase db;
     sourceFileInfo = QFileInfo(file);
@@ -205,7 +202,6 @@ bool KNewFileMenuSingleton::Entry::parseFile(QString file)
         if (!QFileInfo(templatePath).isReadable() && QFileInfo(sourceFileInfo).isNativePath()) {
             return false;
         }
-        mimeType = db.mimeTypeForFile(templatePath);
     }
     // Parse non-.desktop files
     else {
@@ -214,9 +210,10 @@ bool KNewFileMenuSingleton::Entry::parseFile(QString file)
         }
         url = QUrl(file);
         templatePath = file;
-        mimeType = db.mimeTypeForFile(file);
     }
 
+    // fallbacks
+    mimeType = db.mimeTypeForFile(templatePath);
     const QString fileName = sourceFileInfo.fileName();
     if (key.isEmpty()) {
         key = fileName;
@@ -747,8 +744,6 @@ void KNewFileMenuPrivate::executeStrategy()
         QUrl dest = u;
         dest.setPath(Utils::concatPaths(dest.path(), KIO::encodeFileName(chosenFileName)));
 
-        QList<QUrl> lstSrc;
-        lstSrc.append(uSrc);
         KIO::Job *kjob;
         if (m_copyData.m_isSymlink) {
             KIO::CopyJob *linkJob = KIO::linkAs(uSrc, dest);
@@ -903,7 +898,7 @@ void KNewFileMenuPrivate::slotActionTriggered(QAction *action)
     Q_ASSERT(id > 0);
 
     KNewFileMenuSingleton *s = kNewMenuGlobals();
-    const KNewFileMenuSingleton::Entry entry = s->templatesList->at(id - 1);
+    const KNewFileMenuSingleton::Entry &entry = s->templatesList->at(id - 1);
 
     const bool createSymlink = entry.templatePath == QLatin1String("__CREATE_SYMLINK__");
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.