From 908cfca9207be06d7d22ca065662e625a9dd6a35 Mon Sep 17 00:00:00 2001 From: kate Date: Sat, 29 Jan 2022 02:44:57 +0800 Subject: [PATCH] feat: sync setting terminal --- mimetype/mimeappmanager.cpp | 18 +++++++++++++++++- mimetype/xdgdesktopfile.cpp | 5 +++++ mimetype/xdgdesktopfile.h | 2 ++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/mimetype/mimeappmanager.cpp b/mimetype/mimeappmanager.cpp index cad9111..9505f69 100644 --- a/mimetype/mimeappmanager.cpp +++ b/mimetype/mimeappmanager.cpp @@ -448,7 +448,23 @@ void MimeAppManager::launchTerminal(const QString &path) if (m_terminalApps.isEmpty()) return; - QString command = m_terminalApps.first().value("Exec").toString(); + QSettings settings("cutefishos", "defaultApps"); + QString defaultTerminal = settings.value("terminal").toString(); + QString command; + + if (!defaultTerminal.isEmpty()) { + for (const XdgDesktopFile &f : m_terminalApps) { + if (f.fileName().contains(defaultTerminal)) { + command = f.value("Exec").toString(); + break; + } + } + } + + if (command.isEmpty()) { + command = m_terminalApps.first().value("Exec").toString(); + } + FileLauncher::startDetached(command, path, QStringList()); } diff --git a/mimetype/xdgdesktopfile.cpp b/mimetype/xdgdesktopfile.cpp index 75c743e..de7e7ea 100644 --- a/mimetype/xdgdesktopfile.cpp +++ b/mimetype/xdgdesktopfile.cpp @@ -123,6 +123,11 @@ QString XdgDesktopFile::prefix() const return QLatin1String("Desktop Entry"); } +QString XdgDesktopFile::fileName() const +{ + return m_fileName; +} + bool XdgDesktopFile::read(const QString &prefix) { QFile file(m_fileName); diff --git a/mimetype/xdgdesktopfile.h b/mimetype/xdgdesktopfile.h index 2513c49..ae65bfa 100644 --- a/mimetype/xdgdesktopfile.h +++ b/mimetype/xdgdesktopfile.h @@ -42,6 +42,8 @@ public: QString localeName() const; QString prefix() const; + QString fileName() const; + private: bool read(const QString &prefix);